The XML elements are the basic building block of the XML document. It is used as a container to store text elements, attributes, media objects etc. Every XML documents contain at least one element whose scopes are delimited by start and end tags or in case of empty elements it is delimited by an empty tag.
<element-name attributes> Contents...</element-name>
- element-name: It is the name of element.
- attributes: The attributes are used to define the XML element property and these attributes are separated by white space. It associates the name with a value, which is a string of characters.
name="Geeks" Here, Geeks represents the value of attribute
Rules to define XML elements: There are some rules to create XML elements which are given below:
- An element an contain alphanumeric values or characters. But only three special characters are required in the names these are hyphen, underscore and period.
- Names are case sensitive. It means lower case letters have different meaning and upper case characters have different meaning. For example address, Address, aDDress are different names.
- Both start and end tags for elements need to be same.
- An element, which is a container, can contain text or elements
Empty Elements: An element in XML document which does not contains the content is known as Empty Element. The basic syntax of empty element in XML as follows:
Example 1: Following is the example of an XML document describing the address of a college student using XML elements.
G4G Geeksforgeeks 2345456767
xyz abc 80% 98%
- Web technologies | HTML and XML | Question 1
- XML | Basics
- Displaying XML Using CSS
- Java Architecture for XML Binding ( JAXB ) | Set-1
- Displaying XML Using XSLT
- Difference between JSON and XML
- XML | Syntax
- XML | Tags
- HTML vs XML
- XML | Attributes
- How to convert XML file into array in PHP?
- Convert multidimensional array to XML file in PHP
- XML full form
- PHP | XMLReader XML() Function
- How to generate an XML file dynamically using PHP?
- How to parse and process HTML/XML using PHP ?
- ReactJS | Rendering Elements
- How to prevent parents of floated elements from collapsing in CSS?
- PHP | Separate odd and even elements from array without using loop
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.