How to Write an XML Document (Beginner)
May 17th, 2009 Posted in Technology
Ever wanted to learn how to code in XML? Well here is a simple tutorial that helps to scratch the surface of XML a little a give you an idea of how you can use it. XML is useful because things like an RSS feed or a Twitter feed get there information from an XML file. So, let’s get started….
XML is great because you create your own tags. If you are familiar with HTML, you know that a tag is two of these: <> with text in between. Since you will eventually go back and use another language like PHP to read the XML, you can make any kind of tag you want. This is an example of organizing a music library:
<music>
−
<rock>
−
<musicians>
<1> Mr. Dude</1>
<2> sfjkdgkfsg</2>
<3>ksfdggkasfdgfk</3>
<4> ksfdgkdgfk</4>
</musicians>
−
<songs>
<Song1>
song1.mp3
</Song1>
<Song2>
song2.mp3
</Song2>
</songs>
</rock>
−
<hiphop>
−
<musicians>
1. Mr. Dude
2. sfjkdgkfsg
3.ksfdggkasfdgfk
4. ksfdgkdgfk
</musicians>
−
<songs>
<Song1>
song1.mp3
</Song1>
<Song2>
song2.mp3
</Song2>
</songs>
</hiphop>
−
<jazz>
−
<musicians>
1. Mr. Dude
2. sfjkdgkfsg
3.ksfdggkasfdgfk
4. ksfdgkdgfk
</musicians>
−
<songs>
<Song1>
song1.mp3
</Song1>
<Song2>
song2.mp3
</Song2>
</songs>
</jazz>
</music>
As you can see, I created my own tags to fit the content i was organizing. Happy XML-ing.
Ethan
1 Trackback(s)