Tutorial XML Introduction

Discussion in 'Webmaster Tutorials and Resources' started by duyen, Jun 11, 2008.

  1. duyen

    duyen New Member

    Ratings:
    +214 / 0 / -0
    XML Introduction

    By Anman64

    This introduction teaches you:
    • What XML is
    • Why it's used
    • The basics of storing data with XML

    XML is not hard to learn and this tutorial can help you.

    What it is
    • XML stands for Extensible Markup Language
    • XML IS NOT a scripting language and you CANNOT make a website solely out of XML

    Why it's used

    XML is used for storing and transferring data easily and efficiently.

    The Basics of Storing Data

    With XML, storing data is very simple. Because so, it's easier not to explain, and just show code, so you can get a feeling of how it works.

    Here's some example code:

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <gamestore>
    <game>
    <title>SSBB</title>
    <console>Nintendo Wii</console>
    <cost>$50</cost>
    <description>You brawl with people, online or offline</description>
    </game>
    
    <game>
    <title>Metroid Prime III</title>
    <console>Nintendo Wii</console>
    <cost>$35</cost>
    <description>You shoot things</description>
    </game>
    </gamestore>
    The line "<?xml version="1.0" encoding="ISO-8859-1"?>" is to declare what version of XML this is and how it's encoded.

    Link to web page with code.


    As you can see, you can just put whatever you want in the <> tags.

    This tutorial does not cover how to implement this into your web page, but here's a good tutorial to implement XML into an HTML web page.:
    http://www.w3schools.com/xml/xml_to_html.asp


    FAQ:


    Q: What will happen if I make a syntax error?
    A: The XML file will not be able to load, to prevent this I personally recommend this validator.

    Q: Is it really that simple?
    A: For storing data, aye.
    ________________________________

    I know I didn't cover a lot of things, but what do you guys think?

    Probably going to add something on attributes next.
     
    • Like Like x 1
  2. Prometheus

    Prometheus Everything is mutable; nothing is sacred Staff Member

    Ratings:
    +592 / 0 / -0
    I get it.
    Though I would like to see something on how to pull the data and implement it.
     
  3. TheDamien

    TheDamien _

    Ratings:
    +332 / 0 / -0
    Good tutorial. Although XML is a really lame, verbose and internally redundant markup language, it's the best we've got (in terms of standard, at least).

    Also, in the interest of usability I would not recommend parsing XML with JavaScript. I don't know why such a practice is encouraged at w3schools.
     
  4. enouwee

    enouwee Non ex transverso sed deorsum

    Ratings:
    +235 / 0 / -0
    Some points:
    • your "example code" is missing the most important part, the XML declaration.
    • if you want to transform XML into something else, please use XSLT and not some JavaScript scriplet you found on a third-class so-called HTML "expert" school
    • and one can make a webpage exclusively out of XML (images aside). That's the goal of XHTML.

    As for the missing parts, like DTDs and schemas, namespaces and attributes and all the other things, see Wikipedia for a brief introduction.
     
  5. duyen

    duyen New Member

    Ratings:
    +214 / 0 / -0
    >if you want to transform XML into something else, please use XSLT and not some JavaScript scriplet you found on a third-class so-called HTML "expert" school

    "W3C recommend using XSLT instead."

    http://www.w3schools.com/xsl/default.asp

    >your "example code" is missing the most important part, the XML declaration.

    Added

    >and one can make a webpage exclusively out of XML (images aside). That's the goal of XHTML

    Sorry, your right, I was talking about a more dynamic website.
     
  6. duyen

    duyen New Member

    Ratings:
    +214 / 0 / -0
    Bump, looking for more feedback.
     

Share This Page