473,396 Members | 1,965 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,396 software developers and data experts.

XML attributes or node ?

Hi,

When i see a XML file i'm still wondering what are the differences
between writing node data as node attributes or as children nodes.

for example, what are the advantage to write such thing :
<setting>
<client>
<name>Vaporex</name>
<address>Saint Hope st.</address>
</client>
</setting>

instead of :
<setting>
<client name="Vaporex" address="Saint Hope st."></client>
</setting>

my question is the following one :
- which XML structure make a node or attribute research faster ?
Moreover, what should be written as attribute and what should be written
as children node ?

thanks a lot,

RAF
Nov 25 '07 #1
2 5875
Hi RAF,
>my question is the following one :
- which XML structure make a node or attribute research faster ?
I dont have performance measures and experience on this
since i never had to read "really" huge xml files. But i think
this also heavily depends on the kind of xml parser you
use. Dont ask me how the System.Xml Parser handles huge
files. I store huge and important things inside a RDBMS like
SQL Server, Oracle, or another proven and stable system
not a xml file,...

>Moreover, what should be written as attribute and what should be written as
children node ?
This depends on the extensibillity of your application
and sometimes it is a choice of style. It is sometimes
the same with objects in OO Programming. You will
have a vehicle class, it will have a child object that can be
a car class and it can have attributes like a engine="V6"
and its fuel="leaded" and four tires with attribute brand="bridgestone"
then it can be extended with for seats and they will have the
attributes like material = "leather" or color = "red". I am sure
tthat you understand what i am talking about,...

example:

<vehicle>
<car engine="V6" fuel="leaded" model="muscle car">
<tires count="4" brand="bridgestone">
<seats count="4" material="leather" color="red">
</seats>
</tires>
</car>
</vehicle>

Sure this is a simple example but it show the basic structure
how this can be accomplished. The example can be completely
reorganized but this depends, as i said on the extensibility of
your application and how the "range" of your abstraction should
be and how you want it to be,...
Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
Nov 25 '07 #2

"R.A.F." <no*****@nospam.comwrote in message
news:eV**************@TK2MSFTNGP04.phx.gbl...
Hi,

When i see a XML file i'm still wondering what are the differences between
writing node data as node attributes or as children nodes.

for example, what are the advantage to write such thing :
<setting>
<client>
<name>Vaporex</name>
<address>Saint Hope st.</address>
</client>
</setting>

instead of :
<setting>
<client name="Vaporex" address="Saint Hope st."></client>
</setting>

my question is the following one :
- which XML structure make a node or attribute research faster ?
Moreover, what should be written as attribute and what should be written
as children node ?
Hi,

It depends,
It could be the same if you planning to use one atrribute with name "name"
(it's simple to read), but in some situation you will have to use multiple
(1..n) as :

<client>
<name>Vaporex</name>
<name>Vaporex123</name>
</client>

Correct me if i'm wrong.

D.S.
Nov 25 '07 #3

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

Similar topics

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 ...
1
by: juli jul | last post by:
Hello , Here is the code of the function I want to use: private TreeNode CreateTreeNodeFromXmlNode(XmlNode node) { TreeNode tmptreenode = new TreeNode(); if((node.HasChildNodes) &&...
6
by: Hans Kamp | last post by:
My program fails reading XML attributes. A fragment of the code is: private void showXmlNodeAtTreeNode(XmlNodeList xnl, TreeNode tn) { int i; for (i = 0; i < xnl.Count; i++) { XmlNode xn =...
1
by: juli jul | last post by:
Hello , Here is the code of the function I want to use: private TreeNode CreateTreeNodeFromXmlNode(XmlNode node) { TreeNode tmptreenode = new TreeNode(); if((node.HasChildNodes) &&...
2
by: RichardHatcher.com | last post by:
I am writing C code using xpath to extract some data from a XML document. The file uses namespaces, but the name spaces are all listed in the root node of the file as attributes. I want to...
3
by: gregmcmullinjr | last post by:
I am spending alot of time on this group, lets see if we can figure this one out: I'm trying to determine if a node has any attributes at all. I would like to do a shallow copy (<xsl:copy>) if...
5
by: mahesh.nimbalkar | last post by:
When I transform XML, XSLT automatically adds extra attributes to the node which are declared in DTD (default DTD attributes) . I just want XSLT not to add these extra default attributes from DTD....
1
by: jason.cipriani | last post by:
I'm just recently starting to use XML for storing data, and I am wondering when it is more appropriate to use child node values instead of node attributes -- and in general, what are good ways to...
2
by: rds80 | last post by:
In the xml document below, I would like to retrieve the distinct attributes for the element '<Bal>'. However, I haven't had any success. Here is what I have so far: <TRANS> <TRAN...
12
by: blackirish | last post by:
Hi all, I am trying to merge 2 XML files that first of all i need to compare nodes of both files according to 2 attributes in the nodes. If those 3 attributes are equal, i need to replace the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.