Wiki source for FunctionStAXgetData

Show raw source

=====Function getData=====

This function is part of the [[FunctionsStAX StAX]] support.

**getData** returns the data (text) portion of a CHARACTERS event.

getData( $event )


getData return the data of a CHARACTERS event as a string.
The $event argument must be a CHARACTERS event returned from [[FunctionStAXnextEvent nextEvent]].

To use the ""StAX"" functions you need to [[CommandImport import]] them into either the global namespace or a local namespace.
Its recommended that you use a local namespace so that there is less chance of name collisions.

Example: process every START_EVENT for element named "element" and print the attribute value for "attr"

Given an xml file "file.xml"
<element attr="attr1"/>
<element attr="attr2">String</element>


import commands stax=stax
reader=stax:newEventReader( file.xml )
while [ stax:hasNext( $reader CHARACTERS ) ] ; do
event=stax:nextEvent( $reader ) ;
data=stax:getData( $event attr )
echo $data

stax:closeReader $reader





[[FunctionsStAX StAX Functions]]
[[FunctionStAXnewEventReader newEventReader]]
[[FunctionStAXnextEvent nextEvent]]
[[JavaObjects Java Objects]]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki