Java Reference
In-Depth Information
}
}
NodeList list = node.getChildNodes(); // Get the list of
child nodes
if(list.getLength() > 0) { // If there are
some...
//...list them & their children...
// ...by calling listNodes() for each
System.out.println(indent + "Child Nodes of " + nodeName + "
are:");
for(int i = 0 ; i < list.getLength() ; ++i){
listNodes(list.item(i), indent + " ");
}
}
Directory "TryDOM 4 listing elements with attributes"
You can recompile the code with these changes and run the example with the circle with DTD.xml file
that you created when I was discussing DTDs. The content of this file is the following:
<?xml version="1.0"?>
<!DOCTYPE circle
[
<!ELEMENT circle (position)>
<!ATTLIST circle
diameter CDATA #REQUIRED
>
<!ELEMENT position EMPTY>
<!ATTLIST position
x CDATA #REQUIRED
y CDATA #REQUIRED
>
]>
<circle diameter="30">
<position x="30" y="50"/>
</circle>
Directory "TryDOM 4 listing elements with attributes"
The output from the example processing this file should be
DOCTYPE node:
<!ELEMENT circle (position)>
<!ATTLIST circle diameter CDATA #REQUIRED>
<!ELEMENT position EMPTY>
Search WWH ::




Custom Search