Friday, August 24, 2012

ANDROID XML PARSER PART 3



PULL PARSER:

pull-parsing is the "pull" to SAX parsing's "push". SAX pushes content at you by firing events as it encounters constructs within the xml document. 

Pull-parsing lets you ask for (pull) the next significant construct you are interested in.

You still have to take the data in the order it appears in the document - you can't go back and forth through the document like you can with DOM - but you can skip over bits you aren't interested in.



XML Pull Parser is an interface that defines parsing functionality provided in XMLPULL V1 API (visit this website to learn more about API and its implementations).
There are following different kinds of parser depending on which features are set:
  • non-validating parser as defined in XML 1.0 spec when FEATURE_PROCESS_DOCDECL is set to true
  • validating parser as defined in XML 1.0 spec when FEATURE_VALIDATION is true (and that implies that FEATURE_PROCESS_DOCDECL is true)
  • when FEATURE_PROCESS_DOCDECL is false (this is default and if different value is required necessary must be changed before parsing is started) then parser behaves like XML 1.0 compliant non-validating parser under condition that no DOCDECL is present in XML documents (internal entites can still be defined with defineEntityReplacementText()). This mode of operation is intended for operation in constrained environments such as J2ME.
There are two key methods: next() and nextToken(). While next() provides access to high level parsing events, nextToken() allows access to lower level tokens.
The current event state of the parser can be determined by calling the getEventType() method. Initially, the parser is in the START_DOCUMENT state.
The method next() advances the parser to the next event. The int value returned from next determines the current parser state and is identical to the value returned from following calls to getEventType ().
Th following event types are seen by next()
START_TAG
An XML start tag was read.
TEXT
Text content was read; the text content can be retrieved using the getText() method. (when in validating mode next() will not report ignorable whitespace, use nextToken() instead)
END_TAG
An end tag was read
END_DOCUMENT
No more events are available


SOURCE CODE LINK: DOWNLOAD
USEFULL LINK: TUTORIAL


1 comment:

  1. The Borgata Hotel Casino & Spa: Starbucks Coffee Co., A
    The Borgata Hotel Casino 안성 출장마사지 & Spa: 목포 출장안마 Starbucks Coffee Co., 경상북도 출장샵 A-Res. 639. 463. 464. 3131. 464. 익산 출장안마 3131. 태백 출장마사지

    ReplyDelete