Stairway to XML: Level 1 - Introduction to XML

  • H Laforest

    SSC Rookie

    Points: 33

    Well written, straight to the point..


    Will buy anything, if ever, written by this guy..

  • faqr


    Points: 7

    Thank you

    I'm learning something new. today 🙂

  • John Mitchell-245523

    SSC Guru

    Points: 148431

    Thanks SQLBalls, Jon and ACinKC. That makes it a little clearer. I guess as a beginner I'll understand more as I read more and more of the articles to come.


  • ingvar 47353


    Points: 5

    Attributes versus Elements can easily turn into almost religious discussions.

    But one fundamental difference is the ability for an element to contain other elements. An attribute can't contain another attribute.

    And an element is repeteable inside it's parent. So in this sample you have several person in the people element. But you can only have one id="" per person.


    <Phone type="cell">01234567</Phone>

    <Phone type="home">3456789</Phone>



    Won't work with attributes.

    <Person phone_mobile="01234567" phone_home="3456789"/>

    Makes it hard to extend for new types of phone-numbers.


  • Stephen Hirsch


    Points: 1822

    XML started off from SGML as a way to develop authoring languages. For some reason, XML languages are used as databases mostly today. Why that occurred is a long and pointless religious discussion.

    The bottom line is, if you are going to use an XML file as a database, there really is no reason to design a schema that uses elements. Just because you can do something doesn't mean you should.

  • Stan Kulp-439977

    SSCrazy Eights

    Points: 9948

    XML attributes are a legacy from other markup languages. Attributes work well in transformation languages such as HTML or XSL because their tags are actually more akin to commands. Nesting command switches in child elements would make no sense. Placing them inside the tag as attributes makes complete sense. XML, however, is just a container language. It's elements either hold data or they hold other elements that hold data somewhere down the tree. There are no command switches in XML. Arbitrarily placing some data values in elements and other data values in attributes is schizophrenic.

    To be clear, the following two XML statements are equivalent.








    The second style of XML statement (where data that could have been added as a symmetric element has been arbitrarily added as an assymetric attribute) should be avoided.

    When you must deal with XML files that contain attributes, there is a simple solution; convert the attributes to elements.

    The following XSLT stylesheet, courtesy of O'Reilly's CD bookshelfs, does just that for any XML document.

    <?xml version="1.0"?>

    <xsl:stylesheet xmlns:xsl="" version="1.0">

    <xsl:output method="xml"/>

    <xsl:template match="*">

    <xsl:element name="{name()}">

    <xsl:for-each select="@*">

    <xsl:element name="{name()}">

    <xsl:value-of select="."/>



    <xsl:apply-templates select="*|text()"/>




  • Hardy21

    SSCrazy Eights

    Points: 9708

    Very nice article for beginner.


  • jharvey6 76850

    SSC Enthusiast

    Points: 163

    I have a question which may not be easily answered. But my question is; why does the XML parser throw and error when a Tag has a quote " wthin it instead of the entity equivalent " when a normal quote is allowed in an attribute assignment. (id-"1234")

  • theboyholty

    Ten Centuries

    Points: 1050

    Articles / tutorials on SQL XML are rarely pitched at an appropriate level, but this article was a really good start and I'm looking forward to reading the rest of the series.

  • Thomas Abraham


    Points: 10761

    Just piling own with my own Thank You. I already knew most of this from osmosis. But, it really helps to have it laid out in an organized manner.

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

  • SQL2219

    Valued Member

    Points: 69


    This is the best introductory article on XML I have ever seen.

  • DamianC


    Points: 7801

    Excellent introduction Rob

    - Damian

  • webrunner

    One Orange Chip

    Points: 29987

    Thanks for this great introductory article! I look forward to the rest of the Stairway.

    Note, I learned this about the beginning question mark for XML documents:

    It's a prolog – see 'The XML Prolog' in XML Syntax Rules at


    This line is called the XML prolog:
    <?xml version="1.0" encoding="UTF-8"?>
    Note: The XML prolog does not have a closing tag! This is not an error. The prolog is not a part of the XML document.

    A SQL query walks into a bar and sees two tables. He walks up to them and says Can I join you?

Viewing 13 posts - 16 through 28 (of 28 total)

You must be logged in to reply to this topic. Login to reply