No need to generate DTD, useless configuration, no need to generate helper classes, fast. This is the combination of xstream and xpp.
As we all know about xstream, XML pull parser is a high-speed method for parsing XML files, which is much faster than the traditional method (it is found that pull-based Parsing is now popular ). The following is an example of multiple usage methods.
1. The simplest way to useThis is too simple, so I will take the foll
sequence deleted by EXML is a component in the other model. EXML is included in the results shown in this article, but keep this in mind when interpreting performance differences.EXML uses an integrated parser to construct a document representation based on a text document. In addition to text, it does not provide any way to convert or convert from a DOM (or SAX2) to a SAX2 (or DOM) event stream. EXML is open source issued by Mind Electric under a restricted license that prohibits embedding it
; public interface IBeautyParser {/*** parse the input stream and obtain the Beauty List * @ param is * @ return * @ throws Exception */public List
Parse (InputStream is) throws Exception;/***** serialize the Beauty object set, get the XML String * @ param beauties * @ return * @ throws Exception */public String serialize (List
Beauties) throws Exception ;}
Write a BeautyParserImpl implementation class of the above interface in the src directory. Its content is as follows, and t
Process arbitrary XML files
The custom xml file is placed under res/xml/. You can use R. xml. file_name to obtain an XMLResourceParser object. The following is an example of an xml file:
Use javacode to parse xml files layer by layer. The Code is as follows:
Try {// prevent exceptions caused by XML file writing or parsing and analysis mismatch during parsingXmlpullparser xpp = getresources (). getxml (R. xml. rt_test);// Get t
1. Guan Yu(Guanyu.cpp/c/pas)"Problem description"XPP studies the philosophy of astronomy every day, and there are some thoughts that we cannot understand in life.After a dull academic day, XPP opened the http://web.sanguosha.com, ready to use his beloved Guan Yu to abusePeople. Entered the eight-person status bureau, as a master, xpp decisively elected Guan Yu, w
Modifyelement ((Element) child);
25}
26}
27}
XPP
XPP's top-level code (in Listing 10) is the longest of all the examples, and it requires quite a few settings compared to other models.
Listing 10. XPP top-level code
1//Parse the document from input stream
2 m_parserfactory = Xmlpullparserfactory.newinstance ();
3 M_parserfactory.setnamespaceaware (TRUE);
4 Xmlpullparser parser = M_parserfactory.newpu
) throws SAXException {if (qName. equals ("student") {Student = new student (); if (attributes. getLength ()! = 0) {for (int I = 0; I
SAX is based on the event model and performs sequential parsing. the internal implementation is the observer mode, which has the advantage of low memory usage and high efficiency. The disadvantage is that the encoding is relatively complicated.
5. Pull parsing
1. this resolution method is not provided by JDK and needs to be imported to a third-party libr
() function*/
Register int q = RP-> p_priority;/* queue to use */
Register struct proc ** xpp;/* iterate over queue */
Register struct proc * prev_xp;
/* Side-effect for kernel: check if the task's tack still is OK? * /// Check whether the process is a kernel process. If it is a kernel process, perform corresponding processing.If (iskernelp (RP )){
If (* priv (RP)-> s_stack_guard! = Stack_guard)
Panic ("stack overrun by task", proc_nr (RP ));}
# If d
2. huangyueying(Huangyueying.cpp/c/pas)"Problem description"XPP studies the philosophy of astronomy every day, and there are some thoughts that we cannot understand in life.After a dull academic day, XPP opened the http://web.sanguosha.com, ready to use his beloved huangyueyingabuse. Entered the eight-person status bureau, as a master, xpp decisively elected huan
localname is the same as that of "book", it means that a book object is parsed, and a new book object can be created, and localname is saved in tagname. Use attribute to obtain the value of the bookid.
Characters is the content of the parsed text node. The saved tagname is compared with "name" and "price" at this time. If the tagname is the same, the bookname, the bookprice value is encapsulated. In this case, the tagname should be assigned a null value. Otherwise, when it is not empty, the sec
instance xmlserializer.
Next, use xmlserializer to set the output xmlserializer. setoutput, xmlserializer. startdocument ("UTF-8", null) to set XML attributes.
Then, use xmlserializer to create startdocument, starttag, text, endtag, and enddocument.
Code
/** Create XML in PULL mode */
Running result:
3. Pull Parse XML
In PULL mode, XML is parsed throughXmlpullparserClass implementation
First, the XML-parsed instance xpp is obtained through xm
, pull Parser Reference site: http://www.extreme.indiana.edu/xgws/xsoap/xpp This library uses the Parser of the Pull method. There is a pull parser at the bottom of every SAX parser, and this xpp exposes this layer directly to everyone's use. It's worth trying to take full account of the speed. 5.4, Xalan Reference site: http://xml.apache.org/xalan-c/ Xalan is a used to convert an XML document to H
. Another feasible solution is provided in addition to the two main mainstream XML parsing methods of Dom and sax. 5.3, Pull Parser Reference website: http://www.extreme.indiana.edu/xgws/xsoap/xpp This library uses the Parser of the Pull method. There is a pull parser at the bottom of every SAX parser, and this xpp exposes this layer directly to everyone's use. It's worth trying to take full account of t
(color_state_list);//Set button text color
}
Or you can do this:
Xmlresourceparser Xpp=resources.getsystem (). GETXML (R.color.button_text);
try {
colorstatelist csl= colorstatelist.createfromxml (getresources (), xpp);
Btn.settextcolor (CSL);
} catch (Exception e) {
//Todo:handle Exception
}
Finally attach any states that may appear:
For more information on And
addition to the two main mainstream XML parsing methods of Dom and sax. 5.3, pull Parser Reference site: http://www.extreme.indiana.edu/xgws/xsoap/xpp This library uses the Parser of the Pull method. There is a pull parser at the bottom of every SAX parser, and this xpp exposes this layer directly to everyone's use. It's worth trying to take full account of the speed. 5.4, Xalan Reference site: h
. Receive parameter param, parse the result JSON to get the parameter array 2. Take out sign, Remove the SIGN3 in the parameter array. Sort the parameter array key values from the big to the small by natural sort 4. The sorted parameter array is composed of a string in the form of Key=valkey=val, the string is concatenated with the Xpp_key, encrypted once with MD5 (32-bit lowercase), Get sign5. Match sign to the client's sign, if not the same, it could be the parameter being tampered with halfwa
1 Publiclistthrowsxmlpullparserexception2 {3 //gets the asset object for the current program4Assetmanager am =context.getassets ();5 6ListNewArraylist();7 8 Try {9 Ten //opens a file in the asset file as filename and returns the data as a InputStream stream OneInputStream is =am.open (filename); A - //new A Xmlpullparser object instance -Xmlpullparser xpp =Xml.newpul
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.