XML Attributes vs Elements

Discussion in 'ASP .Net' started by David Lozzi, May 14, 2007.

  1. David Lozzi

    David Lozzi Guest

    Howdy,

    I just had a small explosion in my brain, and now i'm a little more confused
    than I was before. I'm fairly new to XML, but understand it for the most
    part in regards to formatting. I have some XML files I use for populating
    dropdowns, like a statelist and other options. These are setup in the XML
    file with attributes.

    <root>
    <state name=Massachusetts abb=MA/>
    </root>

    I also have XML files which I read and write to, using Elements and an XSD
    for the dataset.

    <root>
    <article>
    <title>Here</title>
    <date>5/14/07</date>
    <body>Hi there</body>
    </article>
    </root>

    I know elements are treated as a separate entity, if i may use that word,
    from the parent node. And I understand that data controls like a
    dropdownlist looks for the properties/attributes as specified in its
    properties so the attributes of XML is preferred and easy to use. What
    doesn't make sense is that a Dataset will read from either and write back in
    that same format it read from, now the issue is when a XML file is empty,
    and a dataset writes to it, it defaults to elements instead of attributes,
    which then causes a few issues until I create the XSL file, which then my
    issues are gone. And from there it's OK and will work forever.

    So, I guess I'm stating this more out of frustration with hopes of a little
    clarity if I missed something. It's a lessoned learned, if I deal with XML
    data in attributes i'm fine, and if I start with elements I should expect to
    build a XSD and an XSL file.

    David
    David Lozzi, May 14, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    409
  2. Soren Kuula
    Replies:
    1
    Views:
    447
    Henry S. Thompson
    Dec 1, 2005
  3. Replies:
    3
    Views:
    2,831
  4. Replies:
    2
    Views:
    444
    Martin Honnen
    Feb 11, 2007
  5. Stephen Bannasch
    Replies:
    1
    Views:
    161
Loading...

Share This Page