Pull parsing
Pull-easier to use than DOM and sax
Pull parsing related classes/interfaces
Parsing xml--Package: ORG.XMLPULL.VL
- Xmlpullfactory Class: Parser factory class for creating parser objects
- Xmlpullparser class: Parser class for parsing XML documents
Pull Analytic correlation method
Event codes and methods |
Type |
Describe |
public static final int start_document |
Constant |
Document Start |
public static final int End_ DOCUMENT |
Constant |
End of document |
public static final int Start_tag |
Constant |
Element start |
public static final int End_tag |
Ordinary |
Element end |
public static final int Commet |
Ordinary |
Comments |
public static final int TEXT |
Ordinary |
Element content |
public abstract int Getattributecount () |
Ordinary |
Gets the number of attributes of the element |
Public abstract String getattributename (int index) |
Ordinary |
Gets the property name of the specified index |
Public abstract String getattributevalue (int index) |
Ordinary |
Gets the property contents of the specified index |
public abstract int Geteventtype () |
Ordinary |
Get event code |
Public abstract String GetName () |
Ordinary |
Gets the name of the current element |
Public abstract String GetText () |
Ordinary |
Gets the contents of the current element |
public abstract int Next () |
Ordinary |
Get the next Action event code |
public abstract int Nexttag () |
Ordinary |
Get the next marker |
Public abstract String Nexttext () |
Ordinary |
Gets the next text of the current node |
public abstract void SetInput ( InputStream InputStream, String inputencoding) |
Ordinary |
Set input byte stream for data |
public abstract void SetInput (Reader in) |
Ordinary |
Set the input character stream of the data |
Pull parsing Code
1 //Creating a Parser object2Xmlpullparser parser =xmlpullparserfactory.newinstance (). Newpullparser ();3 //Read Resource file4InputStream is =getresources (). Openrawresource (r.raw.xml file name);5Parser.setinput (IS, "utf-8");//setting the input stream object and encoding format6 intType = Parser.geteventtype ();//Get Event Type7 while(Type! =xmlpullparser.end_document) {8String tagName = Parser.getname ();//Get label name9 if("Specify label name". Equals (TagName) &&type==Xmlpullparser.start_tag) {Ten Parser.next (); OneString value = Parser.gettext ();//Get label Content AToast.maketext (Pull0. This, value,.). Show ();//Informational Alert Box - } - //Execute next label theType =Parser.next (); -}
Pull parsing
XML file parsing "Android 7"--pull parsing