Here are the answers
to the CourseWork for Week 4
Nodes
- How many nodes does the above document have? 9
- How many nodes of the type "Processing instruction" does the above document have? 1
- How many comment nodes does the above document have? 1
- How many element nodes does the above document have? 4
- How many text nodes does the above document have? 2
- List the node types that this document does not use.
CDATASection
Entity Reference
Entity
Document Fragment
Notation
Node Types, names, and values
- What is the nodeType of the 'xdoc' element? 1
- What is the nodeName of the 'xdoc' element? xdoc
- What is the nodeValue of the 'xdoc' element? null
- What is the nodeType of the comment node? 8
- What is the nodeName of the comment node? #comment
- What is the nodeValue of the comment node? "a simple xml document"
- What is the nodeType of the 'Hello XML' node? 3
- What is the nodeName of the 'Hello XML' node? #text
- What is the nodeValue of the 'Hello XML' node? "Hello HTML!"
- What is the nodeType of the first 'greeting' element? 1
- What is the nodeName of the first 'greeting' element? greeting
- What is the nodeValue of the first 'greeting' element? null
- What is the nodeType of the 'applause' element? 2
- What is the nodeName of the 'applause' element? type
- What is the nodeValue of the 'applause' element? "sustained"
Relationships
With regard to the first greeting element
- What is the parent node? xdoc
- What is the first child? text node "Hello HTML!"
- What is the last child? text node "Hello HTML!"
- What is the next sibling? Second greeting element
- What is the previous sibling? null
With regard to the second greeting element
- What is the parent node? xdoc
- What is the first child? text node "Hello XML!"
- What is the last child? text node "Hello XML!"
- What is the next sibling? applause element
- What is the previous sibling? first greeting element
With regard to the applause element
- What is the parent node? xdoc
- What is the first child? Attr applause
- What is the last child? Attr applause
- What is the next sibling? null
- What is the previous sibling? Second greeting element
With regard to the xdoc element
- What is the parent node? document
- What is the first child? first greeting element
- What is the last child? applause element
- What is the next sibling? null
- What is the previous sibling? comment node
With regard to the comment node
- What is the parent node? document
- What is the first child? null
- What is the last child? null
- What is the next sibling? xdoc element
- What is the previous sibling? processing instructions
Lists.
- Make a child list of the xdoc element children and index them.
- Make a child list of the first greeting element children and index them.
- Make a child list of the applause element children and index them.
- Make a list of the second greeting elements and index them.
- Make a list of applause elements and index them.
- Make a list of the applause attributes and index them.