Introduction to the

XML, short for Extensible Markup Language, is a data format used to express complex data structures and is often used to transfer and store data.

Such as:


      
<! DOCTYPEnote SYSTEM "book.dtd">
<book id="1">
    <name>Java Core Technology</name>
    <author>Cay S. Horstmann</author>
    <isbn lang="CN">1234567</isbn>
    <tags>
        <tag>Java</tag>
        <tag>Network</tag>
    </tags>
    <pubDate/>
</book>
Copy the code

Features:

  • Plain text
  • The default encoding is UTF-8

Common special characters are as follows

character said
< <
> >
& &
<books>
   <book sn="SN123124">
       <name>A brief history of time</name>
       <author>Hawking</author>
       <price>75</price>
   </book>
   <book sn="SN12fds3124">
       <name>Java from entry to abandonment</name>
       <author>Mr Wu</author>
       <price>7</price>
       <text><! [CDATA[ fdsjlfsdfjdsl..mm.,<><><> ]]></text>
   </book>
</books>
Copy the code

XML parsing

Both XML and HTML are markup documents that follow THE W3C’s DOM technology for parsing

The Document object represents the entire document and can be in a markup language such as HTML or XML

The early JDK gave us parsing techniques DOM and Sax (obsolete)

Third party analysis:

  • Jdom dom based encapsulation
  • Dom4j encapsulates JDOM
  • Pull is mainly Android mobile phone development and is based on event parsing like SAX

Concrete class library reference