Java for XML: JAXP, JAXB, JAXM, jax-rpc, JAX-WS
Java briefly describes JAXP and Java API for XML Processing. Including XML parsing, validation, query, and transformation. 1) parse the XML into the corresponding memory object, such as the Document in DOM parsing. Currently, Java Se provides the following parsing technologies: DOM, SAX, and STAX. 2) verification. Java Se currently supports DTD and Schema verification. 3) query. The query here refers to the query using XPath. This part has independent APIs. In DOM parsing, it is not used as the query technology to find the upper-lower-level relationship of a node. Because XPath is a W3c-defined XML query technology, XPath is designed for DOM parsing. 4) transform: the content of the XML document is transformed to the specified target. For example, after the XML element is modified using Java API (the memory object is modified), it is saved to the specified location. For three different parsing methods, three different processing methods are formed. But one thing can be the same is the transformation process. All three processing methods can use Transform-related APIs to Transform memory objects to files. 1) DOMDOM is W3C standard API for processing XML, it is the basis of many other standards related to XML processing, not only Java, other such as JavaScript, PHP, MS. NET and other languages have implemented this standard and become the most widely used XML processing method. Of course, to provide more and more powerful functions, Java has many tool classes for DOM direct extension, such as JDOM and DOM4J which many Java programmers are familiar, they are basically an extension of the DOM interface function and retain many dom api features. Many original DOM programmers are familiar with the use of the other two even without any obstacles, the intuitive and easy-to-operate method is favored by many Java programmers. Process Using DOM parsing: 1) Use the Dom parser to parse the Xml file into a Document (a DOM tree) 2) add, delete, modify, and query the Document as needed 3) when necessary, generate a new xml file and search for the Document node, you can use XPath Based on the DOM tree structure. 2) SAXSAX uses the least system resources and the fastest Parsing Method to support XML processing. However, the complicated search method also brings a lot of troubles to the majority of programmers, which is often a headache. At the same time, the support for the XPath query function makes people love and hate it. Process using the SAX Parsing Method: 1) Call various Handler for processing when reading a document using the SAX Parser. 2) generate a new XML document if necessary 3) StAXStAx, Streaming API for XML, which is located in the javax. xml. stream package. The XMLStreamReader interface is used to analyze an XML document, while the XMLStreamWriter interface is used to generate an XML document. XMLEventReader is responsible for analyzing XML events using an object event iteration sub-analysis-this is in contrast to the cursor mechanism used by XMLStreamReader. This tutorial analyzes an XML document based on the StAX implementation in JDK 6.0.