XML Attributes vs Elements

D

David Lozzi

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top