Org.XmlPull.V1.XmlPullParser Class
XML Pull Parser is an interface that defines parsing functionality provided in (visit this website to learn more about API and its implementations).

See Also: XmlPullParser Members

Syntax

[Android.Runtime.Register("org/xmlpull/v1/XmlPullParser")]
public abstract class XmlPullParser

Remarks

XML Pull Parser is an interface that defines parsing functionality provided in (visit this website to learn more about API and its implementations).

There are following different kinds of parser depending on which features are set:

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 method. Initially, the parser is in the state.

The method 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()

An XML start tag was read.
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)
An end tag was read
No more events are available

after first next() or nextToken() (or any other next*() method) is called user application can obtain XML version, standalone and encoding from XML declaration in following ways:

A minimal example for using this API may look as follows:

java Example

 import java.io.IOException;
 import java.io.StringReader;

 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 import org.xmlpull.v1.XmlPullParserFactory;

 public class SimpleXmlPullApp
 {

     public static void main (String args[])
         throws XmlPullParserException, IOException
     {
         XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
         factory.setNamespaceAware(true);
         XmlPullParser xpp = factory.newPullParser();

         xpp.setInput( new StringReader ( "<foo>Hello World!</foo>" ) );
         int eventType = xpp.getEventType();
         while (eventType != XmlPullParser.END_DOCUMENT) {
          if(eventType == XmlPullParser.START_DOCUMENT) {
              System.out.println("Start document");
          } else if(eventType == XmlPullParser.START_TAG) {
              System.out.println("Start tag "+xpp.getName());
          } else if(eventType == XmlPullParser.END_TAG) {
              System.out.println("End tag "+xpp.getName());
          } else if(eventType == XmlPullParser.TEXT) {
              System.out.println("Text "+xpp.getText());
          }
          eventType = xpp.next();
         }
         System.out.println("End document");
     }
 }
 

The above example will generate the following output:

java Example

 Start document
 Start tag foo
 Text Hello World!
 End tag foo
 End document
 

For more details on API usage, please refer to the quick Introduction available at

See Also

[Android Documentation]

Requirements

Namespace: Org.XmlPull.V1
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1