473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

XML Attributes vs Elements

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

May 14 '07 #1
0 1261

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John L. Clark | last post by:
I am curious as to the rationale, and effect, of having default namespaces not applying (directly) to attributes (see http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute without a...
2
by: Stewart Johnson | last post by:
Hey All - I'm stuck while trying to write a schema, hoping someone can provide me with a flash of inspiration. One of the elements I'm writing has two attributes, both of which are optional....
9
by: Soren Kuula | last post by:
Hi, I just can't find namespaces of attributes stated clearly enough in the XML namespace spec. But .. I hear rumors that attributes, unless qualified otherwise, default to the namespace of the...
7
by: Info 3000 | last post by:
Hello, I'm beginner in XML. I have just a little question : I understand that I can write : <Book> <Title> A nice day </Title> <Author> James Nicepen </Author> </Book>
3
by: Stephan Brunner | last post by:
Hi I have created two flavors of an XSLT stylesheet to transform all attributes of an XML document to elements: They both work as expected with MSXML and XMLSPY but throw an exception ...
2
by: Novice | last post by:
Hi all, I have to decide on an XML structure going forward. The structure is going to house a large amount of data. In the past I've always just used the philosophy of "when in doubt use...
1
by: Tod Johnson | last post by:
Hello all, Can't figure it out. :( Assume that we have 2 XML document: Document1 (source): <elements> <elementA attribute1="value1" attribute2="value2" ... /> <elementA attribute1="value1"...
6
by: Jakub.Bednarczuk | last post by:
Hallo everybody I have the problem with getting attributes values and also attributes names. I am reading an xml file with DOM. Lets see an example: file I read <root> <Def></Def>...
2
by: doozer1979 | last post by:
Hello, I'm having a bit of difficulty transforming xml elements into attributes. I want to loop through all of the <person> elements in the document and turn all of its child elements into...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.