Java Reference
In-Depth Information
DOCUMENT_START
Generated when the beginning and end of the document have
been reached (either XML or JSON)
DOCUMENT_END
START_ELEMENT
Generated at the start and end of an XML element (or JSON
object) respectively
END_ELEMENT
TEXT
Generated when textual value of an XML element (or of a JSON
object) is encountered
START_VALUE
Generated when the value of a JSON object has been parsed
END_VALUE
START_ARRAY
Generates an event when the beginning and end of a JSON array
have been reached, respectively
END_ARRAY
START_ARRAY_ELEMENT
Generated at the beginning and end of parsing a JSON array
element, respectively
END_ARRAY_ELEMENT
Custom parsing
The other way to use the PullParser API is to do a linear traversal across the document
yourself, using methods to jump forward to specific locations in the document. To do this, you
make use of the following methods:
forward()
Moves the event cursor forward to the next parsing event
Moves the event cursor forward by the given level into the
document
forward(level:Integer)
seek(element:Object)
Moves the event cursor until the specified element is
encountered
seek(element:Object,
level:Integer)
Moves the event cursor until the element is found at the
specified level
Referring back to the XML document from the Zillow request we saw earlier, we can access
the address value with the following code:
var street = parser.seek(QName{name:"address"})
.forward(2)
.event.text;
The seek() method jumps to the address node, then skips two elements to get to the value
node of the street address (refer to Getting started for XML structure ).
Search WWH ::




Custom Search