Function getName


This function is part of the StAX support.

Name

getName returns the name of a START_ELEMENT event as a QName.


Synopsis

getName( $event )



Description



getName returns the name of an element.
The $event argument must be a START_ELEMENT event returned from nextEvent.



To use the StAX functions you need to 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"
<file>
 <element attr="attr1"/>
 <element attr="attr2">String</element>
</file>


import commands stax=stax
reader=stax:newEventReader( file.xml )
while [ stax:hasNext( $reader START_ELEMENT ) ] ; do
	event=stax:nextEvent( $reader ) ;
	name=stax:getName( $event )
	xtype $name
	echo $name
done

stax:closeReader $reader 


Result
net.sf.saxon.s9api.QName
file
net.sf.saxon.s9api.QName
element
net.sf.saxon.s9api.QName
element





Commands
StAX Functions
newEventReader
nextEvent
Java Objects
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki