The Java EE 5 Tutorial

Iterator Event Types

Table 18–2 lists the XMLEvent types defined in the event iterator API.

Table 18–2 XMLEvent Types

Event Type 



Reports the beginning of a set of XML events, including encoding, XML version, and standalone properties. 


Reports the start of an element, including any attributes and namespace declarations; also provides access to the prefix, namespace URI, and local name of the start tag. 


Reports the end tag of an element. Namespaces that have gone out of scope can be recalled here if they have been explicitly set on their corresponding StartElement.


Corresponds to XML CData sections and CharacterData entities. Note that ignorable white space and significant white space are also reported as Character events.


Character entities can be reported as discrete events, which an application developer can then choose to resolve or pass through unresolved. By default, entities are resolved. Alternatively, if you do not want to report the entity as an event, replacement text can be substituted and reported as Characters.


Reports the target and data for an underlying processing instruction. 


Returns the text of a comment. 


Reports the end of a set of XML events. 


Reports as java.lang.String information about the DTD, if any, associated with the stream, and provides a method for returning custom objects found in the DTD.


Attributes are generally reported as part of a StartElement event. However, there are times when it is desirable to return an attribute as a standalone Attribute event; for example, when a namespace is returned as the result of an XQuery or XPath expression.


As with attributes, namespaces are usually reported as part of a StartElement, but there are times when it is desirable to report a namespace as a discrete Namespace event.

Note that the DTD, EntityDeclaration, EntityReference, NotationDeclaration, and ProcessingInstruction events are only created if the document being processed contains a DTD.