Internet, Networking, & Security Web Development 82 82 people found this article helpful How to Write Your First XML Document by Darla Ferrara Writer Full-time writer and ghostwriter covering a range of topics including marketing, healthcare, and technology. our editorial process LinkedIn Darla Ferrara Updated on September 24, 2020 Tweet Share Email Doug Ross / Getty Images Web Development CSS & HTML Web Design SQL Writing in XML is not difficult. The XML language is a skill that most anyone can learn. The hardest part of learning anything new is getting started. Creating a document in a computer language is best done step-by-step. Working through the basics of writing in XML will help you develop a routine. Once you write the first XML file, you will see the system is easy and flexible. The primary purpose of XML is to contain data that can be accessed by the processor. Take a look at this small inventory list for a store: Inventory Bikes 24-inch Boys Mountain Bike $20024-inch Boys Cruiser Bike $150 Skateboards Acme Sportsmen Skateboard $75Deluxe Boys Skateboard $35 Write a Declaration Statement Declarations provide information to the browser, such as language. A barebones XML declaration statement only requires the language and version. This is enough to establish the page as an XML document. Additional options include encoding and standalone status. Create a Root Element The root element is a container that holds all other elements. It is the first elemental tag for your XML file. Get in the habit of closing your elements as you write them. XML requires closing tags for all elements. Writing both tags at the same time ensures well-formed code and helps to control the structure of the XML. Establish the Child Elements Child elements nest inside the root element. In an inventory listing, you might create sections for different inventory categories. In the example, we have bikes and skateboards. Add Subchild Elements to Hold the Data Subchild elements nest inside of child elements to hold data you want to store. For this example, there are two models of bikes and two of skateboards. One straightforward format for this list involves nesting additional elements inside the subchild to provide more information for each model, such as price. 24-inch Boys Mountain Bike$200.00 24-inch Boys Cruiser Bike$150.00 Acme Sportsmen Skateboard$75.00 Deluxe Boys Skateboard$35.00 This is just one way to work the XML code for this file. Another method would involve using attributes with the elements to identify each section. The advantage of attributes comes when you create formatting for the XML code. Was this page helpful? Thanks for letting us know! Get the Latest Tech News Delivered Every Day Email Address Sign up There was an error. Please try again. You're in! Thanks for signing up. There was an error. Please try again. Thank you for signing up. Tell us why! Other Not enough details Hard to understand Submit