Home Backend Development XML/RSS Tutorial xml learning (1) several file formats of xml

xml learning (1) several file formats of xml

Feb 23, 2017 pm 02:29 PM

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)!


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Can I open an XML file using PowerPoint? Can I open an XML file using PowerPoint? Feb 19, 2024 pm 09:06 PM

Can XML files be opened with PPT? XML, Extensible Markup Language (Extensible Markup Language), is a universal markup language that is widely used in data exchange and data storage. Compared with HTML, XML is more flexible and can define its own tags and data structures, making the storage and exchange of data more convenient and unified. PPT, or PowerPoint, is a software developed by Microsoft for creating presentations. It provides a comprehensive way of

Convert XML data to CSV format in Python Convert XML data to CSV format in Python Aug 11, 2023 pm 07:41 PM

Convert XML data in Python to CSV format XML (ExtensibleMarkupLanguage) is an extensible markup language commonly used for data storage and transmission. CSV (CommaSeparatedValues) is a comma-delimited text file format commonly used for data import and export. When processing data, sometimes it is necessary to convert XML data to CSV format for easy analysis and processing. Python is a powerful

How to open eml file How to open eml file Feb 23, 2024 pm 09:57 PM

eml file is an email file format that contains the original content and information of an email. Usually, the eml file is generated by an email client or email server and saves complete email data, including sender, recipient, subject, body, attachments, etc. To open eml files, you can use the following software: Mail client software: Most mail client software supports opening eml files directly, such as Microsoft Outlook, Microsoft Mail, Thun

Python implements conversion between XML and JSON Python implements conversion between XML and JSON Aug 07, 2023 pm 07:10 PM

Python implements conversion between XML and JSON Introduction: In the daily development process, we often need to convert data between different formats. XML and JSON are common data exchange formats. In Python, we can use various libraries to convert between XML and JSON. This article will introduce several commonly used methods, with code examples. 1. To convert XML to JSON in Python, we can use the xml.etree.ElementTree module

Handling errors and exceptions in XML using Python Handling errors and exceptions in XML using Python Aug 08, 2023 pm 12:25 PM

Handling Errors and Exceptions in XML Using Python XML is a commonly used data format used to store and represent structured data. When we use Python to process XML, sometimes we may encounter some errors and exceptions. In this article, I will introduce how to use Python to handle errors and exceptions in XML, and provide some sample code for reference. Use try-except statement to catch XML parsing errors When we use Python to parse XML, sometimes we may encounter some

Which software can be used to open the .AI file format? Which software can be used to open the .AI file format? Feb 19, 2024 pm 06:03 PM

The AI ​​file format is a proprietary format of Adobe Illustrator and is commonly used to save vector graphics files. Vector graphics can be scaled and edited losslessly, so they are widely used in design, illustration, typography, and other fields. To open AI files, you need to use specialized software, the most important one being Adobe Illustrator software. Adobe Illustrator is specialized software for creating and editing vector graphics. It provides rich tools and functions to help designers create high-quality

Python parsing special characters and escape sequences in XML Python parsing special characters and escape sequences in XML Aug 08, 2023 pm 12:46 PM

Python parses special characters and escape sequences in XML XML (eXtensibleMarkupLanguage) is a commonly used data exchange format used to transfer and store data between different systems. When processing XML files, you often encounter situations that contain special characters and escape sequences, which may cause parsing errors or misinterpretation of the data. Therefore, when parsing XML files using Python, we need to understand how to handle these special characters and escape sequences. 1. Special characters and

Can ai files be opened with ps? Can ai files be opened with ps? Feb 20, 2024 am 10:40 AM

AI files are the file format of Adobe Illustrator software, while PS refers to Adobe Photoshop software. Although both are products of Adobe, they are different software used in different fields of design and image processing. Therefore, under normal circumstances, AI files cannot be opened directly in PS. AI files are file formats specifically used for vector graphics design. It can save graphics, charts, logos, icons and other vector elements, and supports non-destructive editing and amplification. Different from that,

See all articles