













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














Element Text Attr
getNodeName()
getNodeValue()
getNodeType()
getAttributes()
tag name
null
NamedNodeMap
"#text"
text contents
null
name of attribute
value of attribute
null
switch(node.getNodeType()) { case Node.ELEMENT_NODE: Element element = (Element)node; ...; break; case Node.TEXT_NODE: Text text = (Text)node; ... break; case Node.ATTRIBUTE_NODE: Attr attr = (Attr)node; ... break; default: ... } Docsity.com
Input:
Output:
1 novel null 3 #text null 1 chapter null num="1“ 3 #text The Beginning null 3 #text null 1 chapter null num="2“ 3 #text The Middle null 3 #text null 1 chapter null num="3“ 3 #text The End null 3 #text null
Things to think about:
What are the numbers?
Are the nulls in the right places?
Is the indentation as expected?
How could this program be improved?