Reprint: https://www.cnblogs.com/longqingyang/p/5577937.htmlDescribeXML is a kind of universal data Interchange Format, its platform-independent, language-independent, system-independent, to the data integration and interaction brings great convenience. XML is interpreted the same way in different locales, except for the syntax that is implemented differently.XML parsing methods are divided into four kinds: 1, Dom parsing, 2, sax parsing, 3, Jdom pars
Java basics --- XML parsing (1), basics --- xmlXML is a scalable Markup Language
In the XML file, because more information is described, you should use the definition name of the element installed in the program to remove the corresponding content after obtaining an xml file, such an operation is called
First, Brief introductionXStream is an open source framework developed by ThoughtWorks for the transformation of XML data into Java objects and JSON data. It does not require schema or other mapping files to be able to convert between Java objects and XML files, API calls are very convenient, and the extension is power
1. Dom Introduction
Dom is the official W3C standard for XML documents in a way unrelated to the platform and language. Dom is a collection of nodes or information fragments organized by hierarchies. This hierarchy allows developers to search for specific information in the tree. To analyze this structure, you usually need to load the entire document and construct a hierarchy before you can do any work. Because it is based on information layers, Dom i
Nine, The persistence ofIn the example in section eighth, when we manipulate a set of objects, we can specify writer, outputstream to write out the serialized XML data, and we can also specify reader, InputStream to read the serialized XML data. We need to specify the input and output stream when we need to write and read the file, and we need to explicitly call the input and output method to implement the
start, end, text, start, or end of an element, it sends events and programmers write code to respond to these events and save data.
Advantage: the entire document does not need to be transferred in advance, which consumes less resources.
Disadvantages: it is not persistent. After an event, if no data is saved, the data is lost; stateless; only the text can be obtained from the event, but the element of the text is unknown;
Usage scenarios: only a small amount of content in the
JDOM provides a flexible way to operate XML files. it is very simple to use JDOM and the code is concise and readable. We have learned how to use JDOM to parse XML files. This section describes how to use JDOM to modify XML file content.
JDOM provides a flexible way to operate XML files. it is very simple to use JDOM a
processing large documents, dom4j has the same goals as JDOM: ease of use and intuitive operations for Java developers. It is also committed to becoming a more complete solution than JDOM to achieve the goal of essentially handling all Java/XML problems. When this goal is achieved, it places less emphasis on preventing incorrect application behavior than JDOM. D
I. Preface
There are two common methods to parse XML documents using Java: Simple API for XML) the Document Object Module, known as Sax and the Document Object Model Based on trees and nodes, is called Dom. Sun provides the Java API for XML parsing (JAXP) interface to use S
First download Oxygen software (Oxygen XML Editor), currently using a trial version (you can install the software after get trial licence, get free to use 30 days of permission, of course, we encourage you to use genuine software!!! )1 First create a blank XML file, directly click on the following:2 You can use the XML text editing interface, or use the
);@SuppressWarnings ("Unchecked")T t = (t) xstream.fromxml (XMLSTR);return t;}public static void Main (string[] args) {Books Books = Tobean (xmlstring, Books.class);listfor (book book:list) {System.out.println ("name=" + book.getname () + "\tauthor=" + book.getauthor ()+ "\tprice=" + Book.getprice ());}System.out.println (toXml (books));}}In addition to the annotations in the example above, XStream also has several annotations that are often used.@XstreamOmitField Ignore FieldsThis is equivalent
Dom, sax, and JAXP
DOM: Document Object Model
Sax: Simple API for XML
Is there a way for us to replace the parser without having to release it?ProgramWhat about any changes? Jaxp api can help us achieve this. sun has developed the JAXP (Java API for XML Processing) specification to block implementations by specific vendors and allow
corresponding node for them. You cannot directly set the content of the text using the setnodevalue () method of the element object. Instead, you must use the setnodevalue () of the created Text object () to add the created element and its text content to the DOM tree. Look at the previous code to better understand this:
Doc. getdocumentelement (). appendchild (Link );
Finally, do not forget to add the created nodes to the DOM tree. The getdocumentelement () method of the documen
DOM4J is the XML API for java, which is used to read and write XML files. There are many scenarios where dom4j is used to read and write Xml.To use dom4j development, you need to download the appropriate JAR file for import dom4j.Official website Download: HTTP://WWW.DOM4J.ORG/DOM4J-1.6.1/GitHub download: http://dom4j.github.io/After downloading the extract:We ju
[Android XML] Android XML to Java Code series style (3), androidxml
The Code has been restructured in the last month, and it seems much more comfortable, but the overall development progress has not changed .. today we will talk about how to convert the style attribute into Java code.
Conclusion: Referencing System st
java. Io. File ("links. xml "));Transformer. Transform (source, result );
Then the DOM tree is output using XSLT. Here, transformerfactory also applies the factory mode so that the specific code is irrelevant to the specific converter. The implementation method is the same as documentbuilderfactory. The transfrom method of the transformer class accepts
We typically store configuration parameters for Java applications in the properties file. The Java application's properties file can be a normal key-value-based file with the properties extension. can also be an XML file.In this case. We will show you how to output the properties files in both formats through the Java
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.