Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 6th, 2010, 04:36 PM
Authorized User
Points: 153, Level: 3
Points: 153, Level: 3 Points: 153, Level: 3 Points: 153, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: , , .
Posts: 37
Thanks: 5
Thanked 0 Times in 0 Posts
Default Confusion with terminology...

Can anyone tell me what the difference is between an XML Node and an XML Element? I use these terms interchangeably, so for the sake of sounding component and not sounding foolish I would like someone who knows to chime in.
Reply With Quote
  #2 (permalink)  
Old May 6th, 2010, 04:55 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Elements are only one of the many types of node. Attributes, comments, processing instructions are some of the others. You can see a list here: http://www.w3schools.com/dom/dom_nodetype.asp
If you think in terms of object oriented programming then a node is like an abstract base class with the concrete types such as element and attribute inheriting from it.
__________________
Joe
http://joe.fawcett.name/
Reply With Quote
The Following User Says Thank You to joefawcett For This Useful Post:
vb89 (May 6th, 2010)
  #3 (permalink)  
Old May 6th, 2010, 04:59 PM
Authorized User
Points: 153, Level: 3
Points: 153, Level: 3 Points: 153, Level: 3 Points: 153, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: , , .
Posts: 37
Thanks: 5
Thanked 0 Times in 0 Posts
Default

So you're saying elements, attributes, etc are all types of elements?

I was under the following impression:

<test number1="000" number2="111"/>

<test></test> is the node. While test, the number1 and number2 attributes all together are referred to as an element.
Reply With Quote
  #4 (permalink)  
Old May 6th, 2010, 05:06 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

No, elements, attributes etc are all types of nodes.

If you think of it like this:

Node
\--- Element
\--- Attribute
\--- Processing instruction
\--- Text

In your above example there is a node, of type 'element' whose name is 'test'.

That node has some children on its attribute axis. There are two nodes on the attribute axis, of type 'attribute'. The first has a local name of 'number1' and a value of '000' etc.

<test>some text</test>

The above element node (again with a name of 'test') has one child node, of type 'text' with a value of 'some text'.

Hope that helps.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
Reply With Quote
The Following User Says Thank You to samjudson For This Useful Post:
vb89 (May 6th, 2010)
  #5 (permalink)  
Old May 6th, 2010, 05:10 PM
Authorized User
Points: 153, Level: 3
Points: 153, Level: 3 Points: 153, Level: 3 Points: 153, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: , , .
Posts: 37
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Whoops, yeah, I mis-worded my response. I meant, So you're saying elements, attributes, etc are all types of nodes?

Thanks guys!
Reply With Quote
  #6 (permalink)  
Old May 7th, 2010, 06:36 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>So you're saying elements, attributes, etc are all types of nodes?

That's correct. Though in the XPath family of specs we tend to say they are different kinds of node, to avoid any confusion with "type" in the sense that, for example, an attribute or element can be of (= have content of) type integer or date.

Using "Node" to mean "Element" is one of the common terminological slips found among people who use XML but haven't really studied it. Another one that's perhaps even more common, and worse, is using "Tag" to mean "Element". (It's wrong because an element has two tags, a start tag and an end tag.)
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some confusion in these code hpatel_it ASP.NET 1.0 and 1.1 Basics 0 August 30th, 2006 08:19 AM
Terminology? jacob C# 3 July 28th, 2005 03:33 PM
.net Confusion reyboy General .NET 1 December 29th, 2004 08:35 AM
Some confusion as to which SQL to use mark.uk SQL Server 2000 6 August 12th, 2004 10:47 AM



All times are GMT -4. The time now is 08:54 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.