Click to See Complete Forum and Search --> : sibling vs child vs child of child


namedflea
05-16-2009, 04:44 AM
Hi all, new to xml but trying to get my head around it :confused: I have a couple of questions that hope someone can help me with:

In this example:

<abbr title="DOM For N00BS"><em>DOM</em></abbr>;

Is the title attribute node a sibling or child or neither of the <abbr> element node?

Also, if <em> is the firstChild of <abbr>, is then the text "DOM" the firstChild of <em> or is it it's sibling?

Thanks :)

Charles
05-16-2009, 05:56 AM
The text "DOM" is the first child of em and the other DOM is the value of the title attribute of abbr.

dmboyd
05-16-2009, 05:28 PM
In this example:

<abbr title="DOM For N00BS"><em>DOM</em></abbr>;

Is the title attribute node a sibling or child or neither of the <abbr> element node?
Attributes are neither siblings nor children. They are attributes that are attached to the specified element.

Also, if <em> is the firstChild of <abbr>, is then the text "DOM" the firstChild of <em> or is it it's sibling?
The text "DOM" is the value of the <em> node, but it is also a node itself - a text node. <em> is the firstChild of <abbr> as you seem to already understand.

A quick and vastly incomplete DOM "snapshot" that might help to answer your questions:
Element "abbr"
|
+-- childNodes
| |
| +-- Element "em"
| |
| +-- childNodes
| |
| +-- Text "DOM"
+-- attributes
|
+-- Attribute "title" = "DOM for N00BS"

<em> is an element that is a child node of <abbr>. The text "DOM" is a text node that is a child node of <em>. <abbr> has only one attribute, "title", with a value of "DOM for N00BS". There are no siblings as you can see; only child elements.

namedflea
05-16-2009, 07:05 PM
Ahha! Thank you both for taking the time, it makes perfect sense now... I was obsessing lol :)