Abstract: This paper introduces the methods and applications for merging XML documents in XML applications. It has broad application prospects in XML-based applications.
Keywords: XML document parser Elements
In XML applications, the most common and practical way is to read
by IDL attributes. When mapped to a specific language, these attributes are mapped to corresponding methods.
2. Dom instance
With the above introduction, I believe you have a better understanding of Dom. The example below will make you more familiar with Dom.
Let's talk about what this example is to do first. We hope to create a project named Link. some URLs are saved in the XML file. Through a simple program, we can read and display t
software. Now you can see that more and more Java software is using dom4j to read and write XML, and it is particularly worth mentioning that even Sun's JAXM is using DOM4J.
Advantages
① a large number of Java collection classes to facilitate Java developers, while providing some alternative methods of performance.
, some methods are not defined in the Dom and are expressed by IDL attributes. When mapped to a specific language, these attributes are mapped to corresponding methods.
2. Dom instance
With the above introduction, I believe you have a better understanding of Dom. The example below will make you more familiar with Dom.
Let's talk about what this example is to do first. We hope to create a project named Link. some URLs are saved in the XML file. T
properties for the book nodeBook.setattribute ("id", "1");//7: Set text content for book, including four text content, name, Author,price, versionElement name=doc.createelement ("name");//continue to set a grandchild node name.settextcontent ("Core java"); Element author=doc.createelement ("author");//continue to set a grandchild node author.settextcontent ("Horstmann"); Element price=doc.createelement ("price");//continue to set a grandchild node pr
Java model ), so it may also be required in some types of projects (such as using DOM in JavaScript ).SAX performs well, depending on its specific parsing method. A sax detects the upcoming XML Stream but does not load it into the memory (of course, some documents are temporarily hidden in the memory when the XML Stream is read ).Undoubtedly, DOM4J is the winner
Jdom, which does not implement JAXP, but is popular because of its simplicity and becomes the API officially recommended by JCP. It is also a tree-like structural representation of XML, which is much simpler to use than the DOM standard of the consortium. The latest version of Jdom has already started using the JAXP API internally, it will try to invoke the Jaxp API as much as possible, and if not, use its own default
(relative to a non-standard Java model ), so it may also be required in some types of projects (such as using DOM in JavaScript ).SAX performs well, depending on its specific parsing method. A sax detects the upcoming XML Stream but does not load it into the memory (of course, some documents are temporarily hidden in the memory when the XML Stream is read ).Undo
officially recommended by W3C (relative to a non-standard Java model ), so it may also be required in some types of projects (such as using DOM in JavaScript ).
SAX performs well, depending on its specific parsing method. A sax detects the upcoming XML Stream but does not load it into the memory (of course, some documents are temporarily hidden in the memory when the X
also be placed in eclipse at the root of the project BufferedReader = new BufferedReader (New FileReader ("D:\\property.xml"));// Load file Properties.load (BufferedReader) using the Load () method of the Properties object;} catch (FileNotFoundException e) {System.out.println ("File not found!) "); E.printstacktrace ();} catch (IOException e) {System.out.println ("File load failed!") ");} finally{//closes the BufferedReader stream, releasing the resource if (BufferedReader! = null) {try {buffer
Why does this chapter appear? Because XML is so important and widely used! Whether it is data storage or other aspects, such as configuration files. XML is a mechanism for encoding data independent from any programming language. In the field of data exchange, it is becoming very popular! Because of its node-based storage format, it can be used to describe many su
xml| Tutorial Source: http://d23xapp2.cn.ibm.com/developerWorks/education/xml/xmljava/tutorial/xmljava-1-1.html
Fifth Chapter Parser Advanced function
Overview
We have discussed the basics of using an XML parser to work with XML documents. In this section, we will explore some advanced concepts.
First, we'll build
JAXP.
Dom4j is a Java XMLAPI, similar to jdom, used to read and write XML files. Dom4j is a very good JavaXMLAPI with excellent performance, powerful functionality, and extreme ease of use. It is also an open source software that can be found on SourceForge.
Dom4j instance parsing XML
; jaxb:bindings>Note1: The new version of plugin can not only generate Java class, but also help generate the most important methods of object: ToString, Equals, Hashcode, clone, Just configure the plugin on the configuration.configuration> extension>Trueextension> args> arg>-xtostringarg> arg>-xequalsarg> arg>-xhashcodearg> arg>-xcopyablearg> args> plugins> plugin> groupId>Org.jvnet.jaxb2_com
In data migration, a core process of migration is to parse and update local xml files. This operation can be completed simply by using java APIs. In javax. xml. the parsers package provides classes for processing xml files. With t
files. If portability is not considered, use dom4j.
2) The performance of JDOM and Dom is poor during performance testing, and the memory overflows during the testing of 10 m documents. Dom and JDOM are also worth considering in the case of small documents. Although JDOM developers have already stated that they want to focus on performance issues before the official release, from the performance perspective, it is indeed not recommendable. In additi
bind the code to a specific Xalan API.Although JDOM has not implemented JAXP, JDOM is still very popular because of its simplicity and has become an API officially recommended by JCP. It is also a tree structure of XML, which is much easier to use than the w3c dom standard. The latest version of JDOM has started to use JAXP APIs internally. It will try its best to call JAXP APIs. If not, use its default XML
configuration files. If portability is not considered, then use DOM4J.
2) Jdom and Dom perform poorly during performance testing, and memory overflows when testing 10M documents. It is also worth considering using DOM and jdom in small document situations. Although Jdom developers have explained that they expect to focus on performance issues before the formal release, it does not merit a performance perspective. In addition, Dom is still a very good
configuration files. If portability is not considered, then use DOM4J.
2) Jdom and Dom perform poorly during performance testing, and memory overflows when testing 10M documents. It is also worth considering using DOM and jdom in small document situations. Although Jdom developers have explained that they expect to focus on performance issues before the formal release, it does not merit a performance perspective. In addition, Dom is still a very good
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.