473,785 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=Massachuse tts 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 1281

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

Similar topics

1
2723
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 namespace prefix, what is its namespace, if default namespaces do not apply? Are (either of) prefixed or non-prefixed attributes correct? For example, are the following equivalent: <html:br class="foo"...
2
2760
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. I want to express in the schema that there's a relationship between the two -- that the second attribute is optional only if the first one is not specified. ie:
9
1844
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 owner element. Is that right ? Like:
7
1851
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
9927
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 ========================= <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0"
2
3364
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 elements" - but I just read this article: http://msdn.microsoft.com/library/default.asp?URL=/library/en-us/dnexxml/html/xml02212000.asp And there is some indication that you will gain performance benefits from XML that uses attributes rather than...
1
4109
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" attribute2="value2" ... /> ...
6
1901
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> <Elements> <Element att1="1" att2="2" att3="3" //Some attributes are
2
2284
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 attributes of the person element. The code i am using takes the last <person> element and changes all of its elements into attributes of the root node and then removes all of child elements of every person element. This is the code that i am...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.