Welcome visitors of MIC Computer

Welcome to my blog. With this blog you can post your question about computer and programming for absolutely free (free consultation sponsored by MIC Computer).. Well what are you waiting for just feel free to post your question or share with me about your computer / programming experience

Thursday, September 8, 2011

My First XML

XML stand for eXtention Markup Language. XML has make a big different on the web programming and application. By learning XML we can communicate with a lot of different application language, web or desktop programming language. If you want to learn ajax, XSL, DOM, XHTML, web service, RSS, etc, than you need to learn or know about XML. XML can help us to separate display and data. The different betweenjavascript:void(0) XML and HTML is HTML is for display and XML is for the data. XML store and transfer the data.

Now lets start learning. This is the example of XML document:
<?xml version = "1.0" encoding = "utf-8"?>
<computer>
    <PC>
        <mainboard>
            <processor>
                       <manufacture>Intel</manufacture>
                       <type>Core 2 duo</type>
            </processor>
            <memory type="DDR3">
                    <manufacture>VGEN</manufacture>
                    <capacity>2G</capacity>
            </memory>
        </mainboard>
        <sound_card type="onboard" />
        <vga_card type="onboard" />
    </PC>
    <PC>
        <mainboard>
            <processor>
                       <manufacture>AMD</manufacture>
                       <type>Turion</type>
            </processor>
            <memory type="DDR3">
                    <manufacture>VGEN</manufacture>
                    <capacity>2G</capacity>
            </memory>
        </mainboard>
        <sound_card type="PCI Express" />
        <vga_card type="PCI Express" />
    </PC>
</computer>
Well this data is just an example. But it show us how to make it.
This is the rule to make an XML document:

  1. XML document need this at the first of the document <?xml version = "1.0" encoding = "utf-8"?>
  2. encoding = "utf-8" show us how this XML document should be displayed
  3. XML document need to have a root element. In our example, the root element is <computer>.
  4. XML document should be well formed. It is mean that we should put closed tag on every element. As you can see that if we have open a tag like <mainboard>  than we have to close it </mainboard>. But how about a single element like sound_card and vga_card? The syntax to open and close it is like this <sound_card type="anything" / >
  5. A parameter need to be open and close using " or ' like this <sound_card type="anything" />

No comments: