Wiki source for FunctionStAXgetEventType
=====Function getEventType=====
This function is part of the [[FunctionsStAX StAX]] support.
====Name====
**getEventType** returns the event type of the specified ""XMLEvent"" Event as a string
====Synopsis====
getEventType( $event)
====Description====
getEventType returns the event type of the specified ""XMLEvent"" as a string.
The following types are supported (see [[FunctionStAXhasNext hasNext]]).
- START_ELEMENT
- END_ELEMENT
- PROCESSING_INSTRUCTION
- CHARACTERS
- COMMENT
- SPACE
- START_DOCUMENT
- END_DOCUMENT
- ENTITY_REFERENCE
- DTD
- CDATA
- NAMESPACE
- NOTATION_DECLARATION
- ENTITY_DECLARATION
(Note that ATTRIBUTE events will not occur in the input stream, they are contained within START_ELEMENT events).
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===
Given an xml file "file.xml"
%%(xml)
<file xmlns:a="www.test.com">
<a:element attr="attr1"/>
<a:element attr="attr2">String</a:element>
</file>
%%
Print the event type of every event
%%
import commands stax=stax
reader=stax:newEventReader( file.xml )
while [ stax:hasNext( $reader ) ] ; do
event=stax:nextEvent( $reader ) ;
echo stax:getEventType($event)
done
stax:closeReader $reader
%%
Result
%%
START_DOCUMENT
START_ELEMENT
CHARACTERS
START_ELEMENT
END_ELEMENT
CHARACTERS
START_ELEMENT
CHARACTERS
END_ELEMENT
CHARACTERS
END_ELEMENT
END_DOCUMENT
%%
----
[[Commands]]
[[FunctionsStAX StAX Functions]]
[[FunctionStAXnewEventReader newEventReader]]
[[FunctionStAXnextEvent nextEvent]]
[[JavaObjects Java Objects]]
This function is part of the [[FunctionsStAX StAX]] support.
====Name====
**getEventType** returns the event type of the specified ""XMLEvent"" Event as a string
====Synopsis====
getEventType( $event)
====Description====
getEventType returns the event type of the specified ""XMLEvent"" as a string.
The following types are supported (see [[FunctionStAXhasNext hasNext]]).
- START_ELEMENT
- END_ELEMENT
- PROCESSING_INSTRUCTION
- CHARACTERS
- COMMENT
- SPACE
- START_DOCUMENT
- END_DOCUMENT
- ENTITY_REFERENCE
- DTD
- CDATA
- NAMESPACE
- NOTATION_DECLARATION
- ENTITY_DECLARATION
(Note that ATTRIBUTE events will not occur in the input stream, they are contained within START_ELEMENT events).
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===
Given an xml file "file.xml"
%%(xml)
<file xmlns:a="www.test.com">
<a:element attr="attr1"/>
<a:element attr="attr2">String</a:element>
</file>
%%
Print the event type of every event
%%
import commands stax=stax
reader=stax:newEventReader( file.xml )
while [ stax:hasNext( $reader ) ] ; do
event=stax:nextEvent( $reader ) ;
echo stax:getEventType($event)
done
stax:closeReader $reader
%%
Result
%%
START_DOCUMENT
START_ELEMENT
CHARACTERS
START_ELEMENT
END_ELEMENT
CHARACTERS
START_ELEMENT
CHARACTERS
END_ELEMENT
CHARACTERS
END_ELEMENT
END_DOCUMENT
%%
----
[[Commands]]
[[FunctionsStAX StAX Functions]]
[[FunctionStAXnewEventReader newEventReader]]
[[FunctionStAXnextEvent nextEvent]]
[[JavaObjects Java Objects]]