Iterator Event Types
Understanding XMLEventReader requires understanding the various XMLEvent types that can be delivered. Table 1 outlines the major event types for StAX.
Table 1 XMLEvents defined as part of the StAX API.
Event Type |
Description |
StartDocument |
Indicates the beginning of a set of XML events. Includes properties for encoding, XML version, and whether the document is standalone. |
StartElement |
Reports the start of an element. Also includes any attributes and namespace declarations associated with the element. |
EndElement |
Reports the end tag of an element. |
Characters |
Delivers the content of an XML element. It also delivers the content of CDATA sections and CharacterData entities. |
EntityReference |
Reported as discrete events, which an application can choose to resolve or pass through unresolved. By default, entities are resolved. |
ProcessingInstruction |
Reports target and data for a processing instruction. |
Comment |
Returns the text of a comment. |
EndDocument |
Reports the end of a set of XML events. |
DTD |
Reports DTD information as a java.lang.String. |
Attribute |
Attributes are typically reported as part of a StartElement event. However, an attribute can also be delivered as a standalone Attribute event. |
Namespace |
Namespaces are usually reported as part of a StartElement, but sometimes you’re required to report a namespace as a discrete Namespace event. |