getting started with XML

Started by
3 comments, last by agm_ultimatex 15 years, 10 months ago
Let's say I want to create a simple XML script that looked like:

<computer>
<cpu>Intel 3086</cpu>
<motherboard>ASUS</motherboard>
<memory>
<cache>L2</cache>
<disk>80GB</disk>
</memory>
</computer>

What is the process involved in creating this? What software/parsers or other technologies are involved, and what is the sequence in using them all?
Advertisement
You just created it. I presume you used a text editor (or the form entry field here on GameDev).

I think you have missed out on the point of XML: it's a self-describing data language, where formatted data is enclosed in fields that are semantically meaningful and provide information about the relationships between individual data fields. Of itself, it's just text; no special tools are needed to create it. The question is what information you wish to store as XML, what sources you wish to obtain it from, and what destinations you wish to send it to.
XML is a way of labeling information, and a way of organizing it thats better than say writing configuration information to a text file, but no where near as powerful as a database. Its good for simpler tasks essentially. Knowing xml code is good, so you understand how it works. But usually one will create a parser to work with it and write it for them. MSN messenger uses XML for message history. C# uses xml for parts of the GUI.
If you want to concisely and exactly describe the structure of your document, you can use a DTD (simple but somewhat outdated) or an XSD (more complex and powerful... and, IMHO, nicer). That's entirely optional, though... probably only useful if you actually need schema checking or have a code generation tool which takes them as input.

If what you want is to take that file you've got there and access its data from your program, you'll want a good XML library. My preferred library is TinyXML for iterating through the document. TinyXPath allows XPath queries, for more powerful data iteration (though of course you'll need to know XPath for that).
Quote:Original post by Sneftel
If you want to concisely and exactly describe the structure of your document, you can use a DTD (simple but somewhat outdated) or an XSD (more complex and powerful... and, IMHO, nicer). That's entirely optional, though... probably only useful if you actually need schema checking or have a code generation tool which takes them as input.

If what you want is to take that file you've got there and access its data from your program, you'll want a good XML library. My preferred library is TinyXML for iterating through the document. TinyXPath allows XPath queries, for more powerful data iteration (though of course you'll need to know XPath for that).


XSD is also known as a schema. It is nicer than DTD. Im using this book here in class, its pretty good. Im running through the tutorials. http://www.amazon.com/New-Perspectives-Second-Comprehensive-Pespectives/dp/1418860646 My teacher also posted this link for java and xml. But it doesnt really have exercises or anything with it. Its more of a reading book then an educational/academic setting book. http://www.cafeconleche.org/books/xmljava/

This topic is closed to new replies.

Advertisement