xml learning (1) several file formats of xml

黄舟
Release: 2017-02-23 14:29:47
Original
2215 people have browsed it

1. Let’s briefly introduce XML. XML is a text-based markup language, similar to HTML, which can easily store data.

2. Several formats of XML files:

Format 1: View an XML CD directory


<?xml version="1.0" encoding="utf-8" ?>
<CATALOG>
    <CD>
        <TITLE>Empire Burlesque</TITLE>
        <ARTIST>Bob Dylan</ARTIST>
        <COUNTRY>USA</COUNTRY>
        <COMPANY>Columbia</COMPANY>
        <PRICE>10.90</PRICE>
        <YEAR>1985</YEAR>
    </CD>
    <CD>
        <TITLE>Hide your heart</TITLE>
        <ARTIST>Bonnie Tyler</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>CBS Records</COMPANY>
        <PRICE>9.90</PRICE>
        <YEAR>1988</YEAR>
    </CD>
</CATALOG>
Copy after login

Format 2: View an XML school grade directory



<?xml version="1.0" encoding="utf-8" ?>
<config>
    <Header  col1="班级编号" col2="班级名称" col3="年级" col4="学校" col5="男生" col6="女生"  col7="人数"/>
    <row     col1="11" col2="一(一)班" col3="初一" col4="三峡高级中学" col5="20" col6="30"  col7="50"/>
    <row     col1="12" col2="一(二)班" col3="初一" col4="三峡高级中学" col5="18" col6="12"  col7="30"/>
    <row     col1="13" col2="一(三)班" col3="初一" col4="三峡高级中学" col5="16" col6="26"  col7="42"/>
    <row     col1="14" col2="一(四)班" col3="初一" col4="三峡高级中学" col5="23" col6="17"  col7="40"/>
</config>
Copy after login


3, Analysis:


1.xml can only have one root-level element and cannot have multiple root-level elements. , for example, if you add another root-level element in format 2, an error will be reported

2.xml elements can be nested in a loop. The parent element contains child elements, and the child element Level elements can contain their own child elements,

For example, format 1: root elementcontains child elements, and child elements can contain multiple child elements of their own

3. Both elements Medium form:

Form 1[Value] For example:Article title

Form 2 ... Attribute N=[value]/>

For example:

<row     col1="11" col2="一(一)班" col3="初一" col4="三峡高级中学" col5="20" col6="30"  col7="50"/>
Copy after login

The above is the content of xml learning (1) Several file formats of xml. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template