Because the XML interaction data was used in the project, I thought of the tool (XStream) for a time, so I figured out how to use it. Through some of its own programming experience and the strong network, the ultimate easy to get done. You need to prepare the following jar packages (Xstream-1.4.7.jar, Xpp3_min-1.1.4c.jar, Xmlpull-1.1.3.1.jar)1. Writing the corresponding entity
Rootbean
@XStream
Android XMl parsing magic xstream 4: parse complex xml files into objects, androidxstream
For more information about xstream, see:
Android XMl parsing magic xstream 1: parse the aa. xml file in the asset folder of the android Project
Android XMl parsing magic xstream 2: Converting objects into xml
Android XMl parsing m
I. INTRODUCTIONXStream can easily convert Java objects and XML documents to each other, modify a specific attribute and node name, XStream provide annotation annotations,You can complete the description of XML nodes and attributes in JavaBean, and support the conversion of JSON, just provide the relevant jsondriver to complete the conversionOfficial website: http://xstream.codehaus.org/tutorial.htmlTwo. Preparatory work1. Environment Readiness:JAR fil
adding dependencies in 1.pom.xml1.4. 72. Create the Xmlutil class and configure the XStream2.1 Resolve Double underline: XStream occurs when an attribute such as Person_name in an object is converted to XML format In this way, you can replace the double underline with a single underline// Resolve double underline Public Static New Xmlfriendlynamecoder ("-_""_");2.2 Encoding Format:// encoding Format Private Static " UTF-8 ";2.3 Using the DOM p
OverviewThe most recently compiled Java aspects of XML serialization and deserialization of common tool classes, found dom4j and XStream. Dom4j relatively small, very good interpretation of XML, but for the object of XML serialization and deserialization, I still prefer xsteam (PS: Personal hobby bar), here to organize xstream basic knowledge of the entry;UseReferencing MAVEN content 1.4. 8How alias
XStream
The company gives tools to do an interface test, the tool returned to US file format for XML, our platform using Java development, for future data persistence and easy to view the results, you should convert XML to object, so contact with the XStream this class library, although small, but the function is really powerful.
There is an article on the web on the XS
Preface: For XStream do not understand, please see:Android XMl parsing Magic XStream: Parse aa.xml file under Asset folder in Android projectAndroid XML parsing Magic XStream II: Converting objects to XMLAndroid XML parsing Magic XStream Three: Transforming complex objects into XMLAndroid XML parsing Magic
Eight, Object StreamIn the previous example, we are simply outputting XML as a string type or getting and parsing xml from a string, and now we are going to handle the input stream and output stream!1, output stream (ObjectOutputStream)The output stream test program is as follows:Java code
Package CN.TJPU.ZHW.XML.XSTREAM5;
Import java.io.IOException;
Import Java.io.ObjectOutputStream;
Import Com.thoughtworks.xstream.XStream;
public class Outmain {
public static void Mai
Android XMl parsing magic xstream 1: parse the aa. xml file in the asset folder of the android project, xstreamandroid
Introduction
XStream is an open-source project and a simple and practical class library used to serialize the conversion between objects and XML objects.
Parses the content of an XML file into an object or serializes an object into an XML file.
1. Download tool
Add xstream support
Follow these steps to add an xstream library to a new project:
1. Select the new project in Eclipse project explorer and select Properties from the project menu, as shown in Figure 5 ).
Figure 5. Add an xstream Library
2. Click Add external jars and select the xstream-1.2.2.jar from the xstream_hom
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 u
Xsteam intro
Xstream is an open-source product developed by thoughtworks. It uses xpp for conversion between XML and objects. It can be converted between Java objects and XML files without the need for schema or other Mapping Files. API calls are very convenient and powerful in expansion. OfficalSite: http://xstream.codehaus.org/index.html
Official introduction: xstream is a simple library to serialize obj
Android XMl parsing magic xstream 3: Converting complex objects into xml and androidxstream
For more information about xstream, see:
Android XMl parsing magic xstream 1: parse the aa. xml file in the asset folder of the android Project
Android XMl parsing magic xstream 2: Converting objects into xml
1. JavaBeen
packag
= sTATUS; } }
3. generate an XML file:
XStream xStream = new XStream(new DomDriver("GB2312", new XmlFriendlyNameCoder("-_", "_")));This line is converted into underscores
XStream xStream = new XStream(new DomDrive
Preface: For XStream do not understand, please see:Android XMl parsing Magic XStream: Parse aa.xml file under Asset folder in Android projectAndroid XML parsing Magic XStream II: Converting objects to XMLAndroid XML parsing Magic XStream Three: Transforming complex objects into XMLAndroid XML parsing Magic
XStream is a tool for translating Java objects and XML into one another, very good and powerful. Provides support for the direct conversion of all types, arrays, collections, and so on.The core class in XStream is the XStream class, which is generally sufficient to be familiar with this class.Since Xstream.jar relies on xmlpull.jar, you need to import these two j
{ /** * multiple identical tags encapsulated into one collection */ @XStreamImplicit (itemfieldname = "BEAN") Private list Private Dlable D;}Then write a class to set the XStreamProtected XStream Getxstream (class data, class Bean) {XStream XStream = new XStream () {@OverrideProtected Mapperwrappe
XStream Beginner's NotesIntroduction : This chapter is mainly written in the development, there is the sending of XML data, which used the XStream framework for JavaBean and XML data conversion, but in each label, the required interface needs to encapsulate the previous Need to download Xstream-1.3.1.jar packageOn the other functions of
Offical site said, but it does not make it clearly. Especial Parse XML with attributes. Here is my test according to docs from offical websites.
public class XstreamTest { public static void main(String[] args) throws Exception { //convertXml2(); convertObject2(); } public static void convertXml1(){ RendezvousMessage1 message = new RendezvousMessage1(1, false, "part1","part2","part3"); XStream
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.