![]() |
|
| • All Online Courses • New Courses • QuickTips • Word Definitions • Submit a Tutorial • Links • |
|
Learn XML programming in this free XML training course How do I structure my XML documents?Structure in an XML document is very important. Small errors in the structure of your document can have large effects on the overall outcome; pieces may not be displayed correctly, or might not appear at all. If the structure is too damaged, then the entire document might fail to work. So what is the proper method of structuring an XML document? As previously mentioned, all XML documents begin with the XML directive. Open up the previously-saved file, cats.xml, and you’ll find your directive already in place. <?xml version=”1.0”?> <cats>Tooter and Shade are the best cats in the world!</cats> Unfortunately, your file is still missing a few vital elements. The <cats> tags don’t work, and the browser has no idea how to make them work. If you load it up in a browser, you’ll just see a copy of the file, with the various elements in different colors. This is actually useful, however; as long as you see this, then your code is good. The browser doesn’t know what else to do with it, in this case because some of the elements are missing, but the lack of definitive error codes tells you that it’s at least well-coded. Go into the file, between your directive and the content, and get ready to add another vital element to your page. Type the following: <?xml-stylesheet type=”text/css” href=”cats.css”?> Of course, this doesn’t mean much to you right now… in time, though, it’s going to be a vital part of your page. What you just typed is the directions that the browser needs to find the XML processor, or the file that tells it how it should handle the information in the XML document. The line that you just typed tells the browser to find the file called cats.css, and that the file is a Cascading Style Sheet. It also tells it that it’s the stylesheet that it needs for this page. Now your cats.xml file should look like the following, which looks a lot more like an XML file. <?xml version=”1.0”?> <?xml-stylesheet type=”text/css” href=”cats.css”?> <cats>Tooter and Shade are the best cats in the world!</cats> Of course, you’ve still got to define cats.css, but that can wait. You still have to learn a little bit more about XML first… namely the use of elements and attributes. Go ahead and save your cats.xml file, and then we can look at what elements and attributes are.
by John Casteele Find more free Internet tutorials from Learnthat.com. More Information:
Help us by rating this tutorial: [---] [--] [+] [++] [+++] [---] lowest; [+++] highest
|
|
||||||
![]() |
Learn: Free
Tutorials - Links
to Free Tutorials
Understand: Free Technical Definitions
- ExplainThat Whitepapers
Use: Certification Section -
Discussion Forum
Visit Our Network Sites:
About Us : Contact Us : Advertise : Privacy Information