The use of dom4j

Source: Internet
Author: User
Tags cdata comparison processing instruction xml cdata xpath xslt

DOM4J is an open source XML parsing package produced by dom4j.org, which is defined in its Web site as:

DOM4J is a easy to use, open Source library for working with XML, XPath and XSLT on the Java platform using the Java Coll The Ections Framework and with the full support for DOM, SAX and JAXP.

DOM4J is an easy-to-use, open Source Library for Xml,xpath and XSLT. It is applied to the Java platform, with a Java collection framework and full support for Dom,sax and JAXP.

DOM4J is very simple to use. As long as you understand the basic Xml-dom model, you can use it. However, his own guide is only a short page (HTML), but it is quite full. There are few Chinese materials in China. So I write this short tutorial convenient for everyone to use, this article only talks about the basic usage, if need to use deeply, please ... Explore or find other information on your own.

Read the IBM Developer Community article (see appendix) and mention the performance comparisons of some XML parsing packages, where dom4j performance is excellent and ranked among several tests. (In fact, this comparison is also referenced in DOM4J's official documentation) so I used dom4j as an XML parsing tool for this project.

In the domestic more popular is the use of jdom as a parser, both good their length, but dom4j the biggest feature is the use of a large number of interfaces, which is considered more flexible than the main reason for Jdom. Didn't the master say, "interface-oriented programming". More and more dom4j are being used. If you are good at using Jdom, you might as well continue to use it, just look at this article as an understanding and comparison, if you are going to adopt a parser, it is better to use dom4j bar.

Its main interfaces are defined in the ORG.DOM4J package:

Attribute attribute defines the attributes of XML
Branch Branch defines a public behavior for nodes that can contain child nodes such as XML elements (element) and documents (docuemnts).
Cdata CDATA Defines an XML CDATA region
Characterdata Characterdata is an identification excuse for identifying character-based nodes. such as Cdata,comment, Text.
Comment Comment defines the behavior of XML annotations
Document The XML document is defined
DocumentType DocumentType define XML DOCTYPE declaration
Element element defines XML elements
Elementhandler Elementhandler defines the processor for the Element object
ElementPath Used by Elementhandler to get the path-level information currently being processed
Entity Entity defines XML entity
Node Node defines the polymorphic behavior for all XML nodes in the DOM4J
Nodefilter Nodefilter defines the behavior of a filter or predicate that is produced in a dom4j node (predicate)
ProcessingInstruction ProcessingInstruction defines an XML processing instruction.
Text Text defines an XML text node.
Visitor Visitor is used to implement Visitor mode.
Xpath XPath provides an XPath expression after parsing a string

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.