


A detailed introduction to the use of tags and elements in XML
This article mainly introduces the use of tags and elements in XML. It is the basic knowledge for introductory learning of XML. Friends who need it can refer to it
tag
us Let's learn about one of the most important parts of XML, XML tags. XML tags are the basis of XML. They define the scope of an element in XML. They can also be used to insert comments, declare settings required for the parsing environment, and insert specific directives.
XML tags can generally be classified as follows:
Start tag
Each starting non-empty XML element is marked as a start tag. Here is an example of a start tag:
<address>
End tag
Every element with a start tag should be closed with a closing tag. Here is an example of a closing tag:
</address>
Note that the closing tag contains a slash ("/") in front of the element name.
Empty tag
The text that appears between the start tag and the end tag is called content. Elements with no content are called empty elements. Empty elements are represented in the following two ways:
(1) The start tag is followed by an end tag, as shown below:
<hr></hr>
(2) In the true sense The empty element tag looks like this:
<hr />
The empty element tag can be used for any element that has no content.
XML tag rules
The following are the rules to follow when using XML tags:
Rule 1
XML tags are case-sensitive. The following line of code is an example of bad syntax because the two tags are not the same case, which is considered bad syntax in XML.
<address>This is wrong syntax
The following code shows the correct approach, where the opening and closing tag names use the same case.
<address>This is correct syntax</address>
Rule 2
XML tags must be closed in the appropriate order, for example, an XML tag opened inside another element must be closed before the outer element is closed. For example:
<outer_element> <internal_element> This tag is closed before the outer_element </internal_element> </outer_element>
Element
XML elements can be defined as building blocks of XML. Elements can appear as containers that hold text, elements, attributes, media objects, or any of these.
Every XML document contains one or more elements, whose scope is bounded by start and end tags, or an empty element tag to represent an empty element.
Syntax
The following is the syntax for writing an XML element:
<element-name attribute1 attribute2> ....content </element-name>
Here
element-name: Represents the name of the element. The names between the opening and closing tags must match.
attribute1, attribute2: It is the element attributes separated by spaces. Attributes define the properties of an element. It associates a name and a string value. Attributes are written in the following form:
name = "value"
Attribute_name_ is followed by an = sign and a string value wrapped in double quotes (" ") or single quotes (' ').
Empty element
The syntax of an empty element (an element with no content) is as follows:
Here is an XML document using various XML elements:
<?xml version="1.0"?> <contact-info> <address category="residence"> <name>Tanmay Patil</name> <company>TutorialsPoint</company> <phone>(011) 123-4567</phone> <address/> </contact-info>
XML Element Rules
XML elements need to follow the following rules:
Element_names can contain any alphanumeric characters. The only tag symbols allowed in names are hyphen (-), underscore (), and period (.).
Element names are case-sensitive. For example, Address, address and ADDRESS are different element names. The opening and closing tags of the
element must be the same.
An element is a container, which can contain text or elements, as you can see in the example above.
The above is the detailed content of A detailed introduction to the use of tags and elements in XML. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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

This tutorial shows you how to find specific text or phrases on all open tabs in Chrome or Edge on Windows. Is there a way to do a text search on all open tabs in Chrome? Yes, you can use a free external web extension in Chrome to perform text searches on all open tabs without having to switch tabs manually. Some extensions like TabSearch and Ctrl-FPlus can help you achieve this easily. How to search text across all tabs in Google Chrome? Ctrl-FPlus is a free extension that makes it easy for users to search for a specific word, phrase or text across all tabs of their browser window. This expansion

How to handle XML and JSON data formats in C# development requires specific code examples. In modern software development, XML and JSON are two widely used data formats. XML (Extensible Markup Language) is a markup language used to store and transmit data, while JSON (JavaScript Object Notation) is a lightweight data exchange format. In C# development, we often need to process and operate XML and JSON data. This article will focus on how to use C# to process these two data formats, and attach

As a popular short video social platform, Douyin has a huge user base. For Douyin creators, using tags to attract traffic is an effective way to increase the exposure of content and attract attention. So, how does Douyin use tags to attract traffic? This article will answer this question in detail for you and introduce related techniques. 1. How to add tags on Douyin to attract traffic? When posting a video, make sure to choose tags that are relevant to the content. These tags should cover the topic and keywords of your video to make it easier for users to find your video through tags. Leveraging popular hashtags is an effective way to increase your video’s exposure. Research current popular tags and trends and incorporate them into your video descriptions and tags. These popular tags usually have higher visibility and can attract the attention of more viewers. 3. Label

When browsing Douyin works, we often see a clock icon behind the tag. So, what exactly is this clock? This article will focus on the discussion of "What is the clock behind the Douyin label", hoping to provide some useful reference for your use of Douyin. 1. What is the clock behind the Douyin label? Douyin will launch some hot topic challenges. When users participate, they will see a clock icon after the tag, which means that the work is participating in the topic challenge and displays the remaining time of the challenge. For some time-sensitive content, such as holidays, special events, etc., Douyin will attach a clock icon after the label to remind users of the validity period of the content. 3. Popular tags: When a tag becomes popular, Douyin will add a clock icon after the tag to indicate that the tag is

Detailed explanation of the video tag in HTML The video tag in HTML5 is a tag used to play videos on web pages. It can render videos using different formats, such as MP4, WebM, Ogg, and more. In this article, we will introduce the use of video tag in detail and provide specific code examples. Basic Structure The following is the basic structure of the video tag:

CSS transition effect: How to achieve the sliding effect of elements Introduction: In web design, the dynamic effect of elements can improve the user experience, among which the sliding effect is a common and popular transition effect. Through the transition property of CSS, we can easily achieve the sliding animation effect of elements. This article will introduce how to use CSS transition properties to achieve the sliding effect of elements, and provide specific code examples to help readers better understand and apply. 1. Introduction to CSS transition attribute transition CSS transition attribute tra

CSS transformation: How to achieve the rotation effect of elements requires specific code examples. In web design, animation effects are one of the important ways to improve user experience and attract user attention, and rotation animation is one of the more classic ones. In CSS, you can use the "transform" attribute to achieve various deformation effects of elements, including rotation. This article will introduce in detail how to use CSS "transform" to achieve the rotation effect of elements, and provide specific code examples. 1. How to use CSS’s “transf
