XML Syntax
If you have already programmed in HTML, XML syntax shouldn't be that much of a leap to grasp. While there are a couple of new items in XML, it is still just a markup language that relies on tags to get the job done.XML Syntax: Our Example XML Document
This lesson will analyze a real XML file to point out the syntax used to create a Well-Formed XML document. This XML document was used to keep track of students in an Computer Application's Course.XML Code:
<?xml version="1.0" encoding="ISO-8859-15"?> <class_list> <student> <name>Robert</name> <grade>A+</grade> </student> <student> <name>Lenard</name> <grade>A-</grade> </student> </class_list>
Let's take a look at XML syntax by looking at the different parts of this document. Note: This is just an overview of XML's syntax and there are links to more information provided in this lesson.
XML Prolog (optional)
I think the only thing not easily understandable in our XML document is that first line with all the symbols and attributes. This rather confusing line in our XML document is referred to as the XML Prolog.XML Code:
<?xml version="1.0" encoding="ISO-8859-15"?>
XML Tag
The XML tag is very similar to that of the HTML tag. Each element is marked with an opening tag and a closing tag. Below, we have highlighted both the opening and closing tags from a piece of our example XML file.XML Code:
<name>Robert</name> <grade>A+</grade>
XML Elements
XML Elements are the meat and potatoes of XML. They contain the opening and closing tags, child elements, and data. In our XML document the student element is comprised of all of the following information. Notice how it has a couple of child elements.XML Code:
<student> <name>Robert</name> <grade>A+</grade> </student>
0 comments:
Post a Comment