The DOM XML parsing and DOM4J

XML is a tree structure

XML represents the whole way through the node

 

 

 

sutdent.xml Document: document node xml file

students Element: junction element using <> tag

number Attr: the junction element attribute property name = "attribute value"

Day Text: text content between node elements

DOM: Document Object Model: Document Object Model, the document described as a member of objects

XML operations in Java code HTML or JS code operation

 

DOM parsing features

1. When loaded, one-off the entire XML document is loaded into memory, forming a tree (Document Object) in memory.

2. After using the code operation Document, is an XML file memory DOM tree, and a local disk is actually not directly related to operations.

3. Since the operation of the memory among dom, xml disk contents will not change, to be synchronized so that both sides be consistent

(Query does not need synchronization, data changes only when it needs to be synchronized)

4. Cons: If the XML file is too large, it may cause memory overflow

 

DOM parsing step

Represented here by the code:

 

 

 

 

 

 

Sax resolve introduction

Read line by line, based on event-driven

Pros: do not take up memory and speed

Disadvantages: can only read, can not write back

 

 

DOM4j Introduction

DOM4J is dom4j.org produced an open source XML parsing package

dom4j is a very good JavaXML API, with excellent performance, powerful and extremely easy-to-use features, its performance over the sun's official dom technology, software, and it is also an open-source

More and more Java software are in use dom4j to read and write XML, is particularly worth mentioning is that even the Sun is also used JAXM dom4j. This was the jar package must be used, Hibernate also use it to read and write configuration files.

 

 

 

Old nine school community members produced

Guess you like

Origin www.cnblogs.com/ljxt/p/11608984.html