search
HomeBackend DevelopmentXML/RSS TutorialXML Guide - XML ​​Elements

XML Guide - XML ​​Elements

Feb 11, 2017 pm 03:26 PM


XML elements are extensible and are related to each other.
XML elements have simple naming rules.

XML elements are extensible
XML documents can be expanded to carry more information.
Look at the following XML note example:

<note> 
<to>Lin</to> 
<from>Ordm</from> 
<body>Don&#39;t forget me this weekend!</body> 
</note>


Let's imagine a program that can read this XML document and interpret the XML elements (, < ;from>, and ) software, the possible output is as follows:
MESSAGE
To: Lin
From: Ordm
Don't forget me this weekend!

Let's imagine again that if Ordm, the author of the note, adds some additional information to this XML document, as shown below:

<note> 
<date>2002-12-24</date> 
<to>Lin</to> 
<from>Ordm</from> 
<heading>Reminder</heading> 
<body>Don&#39;t forget me this weekend!</body> 
</note>


Will the original application interrupt or crash?
Won't. The application will still interpret the , , and elements correctly and produce the same output.
XML documents are extensible!

XML elements are related to each other
The relationship between XML elements is the relationship between parent elements and child elements.
In order to better understand XML terminology, you must understand the relationship between XML elements and how the content of the elements is described.
Imagine there is such a book:
Signature: XML Guide
Chapter 1: Introduction to XML
What is HTML
What is XML
Chapter 2: XML Syntax
XML elements must have closing tags
XML elements must be nested correctly


We can use XML documents to describe this book:

<book> 
<title>XML 指南</title> 
<prod id="33-657" media="paper"></prod> 
<chapter>XML入门简介 
<para>什么是HTML</para> 
<para>什么是XML</para> 
</chapter> 
<chapter>XML语法 
<para>XML元素必须有结束标记</para> 
<para>XML元素必须正确的嵌套</para> 
</chapter> 
</book>

In the above In the code, the Book element is the root element of the XML document, and the title element and chapter element are child elements of the book element. The Book element is the parent element of the title element and chapter element. The title element, prod element and chapter element are horizontal elements because they all have the same parent element.

Contents of XML elements
XML elements have different contents.
XML element refers to the content from the start tag to the end tag of the element.
XML elements have element content, mixed content, simple content or empty content. Each element can have its own properties.
In the above example, the book element has element content, which should be because the book element contains other elements. The Chapter element has mixed content because it contains text and other elements. The para element has simple content because it only has simple text inside it. The prod element has empty content because it does not carry any information.
In the above example, only the prod element has attributes, the id attribute value is 33-657, and the media attribute value is paper.


XML element naming
XML element naming must comply with the following rules:
The name of the element can contain letters, numbers and other characters.
The name of the element cannot start with a number or punctuation mark.
The name of the element cannot start with XML (or xml, Xml, xMl...).
The name of the element cannot contain spaces.
You must also pay attention to the following simple rules for your own "invented" XML elements:
Any name can be used, no reserved words (except XML), but the name of the element should be readable, and the name should be used Underscore is a good choice.
For example: , .
Try to avoid using "-" and "." because it may cause confusion.
The name of the element can be as long as you want, but don't make it too exaggerated. Naming should follow the principle of being simple and easy to read. For example: is a good name, but is wordy.
XML documents often correspond to data tables. We should try to keep the naming of fields in the database consistent with the naming in the corresponding XML document, so as to facilitate data transformation.
Non-English/characters/strings can also be used as names of XML elements, such as These are completely legal names. However, some software does not support this naming well, so try to use English letters for naming.
Do not use ":" in XML element naming, because XML namespaces require this very special character. ​​​​​

The above is the content of XML Guide - XML ​​elements. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement
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
Mastering Well-Formed XML: Best Practices for Data ExchangeMastering Well-Formed XML: Best Practices for Data ExchangeMay 14, 2025 am 12:05 AM

Well-formedXMLiscrucialfordataexchangebecauseitensurescorrectparsingandunderstandingacrosssystems.1)Startwithadeclarationlike.2)Ensureeveryopeningtaghasaclosingtagandelementsareproperlynested.3)Useattributescorrectly,enclosingvaluesinquotesandavoidin

XML: Is it still used?XML: Is it still used?May 13, 2025 pm 03:13 PM

XMLisstillusedduetoitsstructurednature,humanreadability,andwidespreadadoptioninenterpriseenvironments.1)Itfacilitatesdataexchangeinsectorslikefinance(SWIFT)andhealthcare(HL7).2)Itshuman-readableformataidsinmanualdatainspectionandediting.3)XMLisusedin

The Anatomy of an RSS Document: Structure and ElementsThe Anatomy of an RSS Document: Structure and ElementsMay 10, 2025 am 12:23 AM

The structure of an RSS document includes three main elements: 1.: root element, defining the RSS version; 2.: Containing channel information, such as title, link, and description; 3.: Representing specific content entries, including title, link, description, etc.

Understanding RSS Documents: A Comprehensive GuideUnderstanding RSS Documents: A Comprehensive GuideMay 09, 2025 am 12:15 AM

RSS documents are a simple subscription mechanism to publish content updates through XML files. 1. The RSS document structure consists of and elements and contains multiple elements. 2. Use RSS readers to subscribe to the channel and extract information by parsing XML. 3. Advanced usage includes filtering and sorting using the feedparser library. 4. Common errors include XML parsing and encoding issues. XML format and encoding need to be verified during debugging. 5. Performance optimization suggestions include cache RSS documents and asynchronous parsing.

RSS, XML and the Modern Web: A Content Syndication Deep DiveRSS, XML and the Modern Web: A Content Syndication Deep DiveMay 08, 2025 am 12:14 AM

RSS and XML are still important in the modern web. 1.RSS is used to publish and distribute content, and users can subscribe and get updates through the RSS reader. 2. XML is a markup language and supports data storage and exchange, and RSS files are based on XML.

Beyond Basics: Advanced RSS Features Enabled by XMLBeyond Basics: Advanced RSS Features Enabled by XMLMay 07, 2025 am 12:12 AM

RSS enables multimedia content embedding, conditional subscription, and performance and security optimization. 1) Embed multimedia content such as audio and video through tags. 2) Use XML namespace to implement conditional subscriptions, allowing subscribers to filter content based on specific conditions. 3) Optimize the performance and security of RSSFeed through CDATA section and XMLSchema to ensure stability and compliance with standards.

Decoding RSS: An XML Primer for Web DevelopersDecoding RSS: An XML Primer for Web DevelopersMay 06, 2025 am 12:05 AM

RSS is an XML-based format used to publish frequently updated data. As a web developer, understanding RSS can improve content aggregation and automation update capabilities. By learning RSS structure, parsing and generation methods, you will be able to handle RSSfeeds confidently and optimize your web development skills.

JSON vs. XML: Why RSS Chose XMLJSON vs. XML: Why RSS Chose XMLMay 05, 2025 am 12:01 AM

RSS chose XML instead of JSON because: 1) XML's structure and verification capabilities are better than JSON, which is suitable for the needs of RSS complex data structures; 2) XML was supported extensively at that time; 3) Early versions of RSS were based on XML and have become a standard.

See all articles

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 Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),