XML | Elements Last Updated : 24 May, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. Syntax: <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. Example: 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 can 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: <elements-name attributename/> Example 1: Following is the example of an XML document describing the address of a college student using XML elements. html <?xml version = “1.0”?> <contactinfo> <address category = “college”> <name>G4G</name> <College>Geeksforgeeks</College> <mobile>2345456767</mobile> </address> </contactinfo> Output: G4G Geeksforgeeks 2345456767 Example 2: html <?xml version = "1.0"?> <student> <_personal_details = "Personal Details"> <name>xyz</name> <father_name>abc</father_name> </personal_details> <edu_details = "Educational Details"> <hsc_perc>80%</hsc_perc> <ssc_perc>98%</ssc_perc> </edu_details> </student> Output: xyz abc 80% 98% Comment More infoAdvertise with us Next Article XML | Elements A Akashkumar17 Follow Improve Article Tags : HTML HTML and XML Similar Reads XML | Tags XML tags are the important features of XML document. It is similar to HTML but XML is more flexible then HTML. It allows to create new tags (user defined tags). The first element of XML document is called root element. The simple XML document contain opening tag and closing tag. The XML tags are cas 2 min read XML | Syntax Prerequisite: XML | Basics In this article, we are going to discuss XML syntax rule which is used while writing an XML document or an XML application. It is a very simple and straight forward to learn and code. Below is a complete XML document to discuss each component in detail. XML <?xml versi 3 min read What are XML Entities ? XML is a way to organize information on the internet. It's like a recipe that tells computers how to understand and use the information. Entities in XML are like ingredients in a recipe. They help you define and reuse parts of your information, making it easier to manage and share. What is XML?XML s 8 min read HTML vs XML HTML (Hyper Text Markup Language) is used to create web pages and web applications. It is a markup language. By HTML we can create our static page. It is used for displaying the data not to transport the data. HTML is a combination of Hypertext and Markup language. Hypertext defines the link between 3 min read How to open an XML file ? XML stands for eXtensible Markup Language. It defines the format of data and it is similar to HTML as both are markup languages but while HTML has a predefined set of standard tags, XML has user-defined tags, although has a starting standard tag: <?xml version=â1.0â encoding=âUTF-8â?>XML is a 3 min read Like