This is my xml file:
<recipelist>
−
<recipe>
<name>couscous</name>
−
<categories>
<category>Side Dish</category>
<category>Vegan</category>
</categories>
<link>couscous.xml</link>
</recipe>
−
<recipe>
<name>damper</name>
<description>
A recipe for traditional Australian damper.
</description>
−
<categories>
<category>Bread</category>
<category>Snack</category>
</categories>
<link>damper.xml</link>
</recipe>
</recipelist>
and this is my DOM: the crrnode is the category value i look up.
The parent is <category>; grandParent is <categories> and grandma is <recipe>
They are all display on the screen except the sibling of grandParent --> name, description and link --> they display "#text" as Name and "3" as Type
recipe
#text
#text
categories
#text
like that. And here is my DOM:
case Node.TEXT_NODE: {
Node parent = currnode.getParentNode();
if (parent != null) {
Node grandParent = parent.getParentNode();
if ((grandParent.getNodeName().equals("categories")) && (parent.getNodeName().equals("category"))) {
String text = currnode.getNodeValue();
if (text.equals("Main Course")) {
if (text.length() > 0) {
Node grandma = grandParent.getParentNode();
Node name = grandma.getFirstChild();
Node des = grandParent.getPreviousSibling();
Node link = grandma.getLastChild();
out.println("<h1>"+grandma.getNodeName()+"</h1>");
out.println("<h1>"+name.getNodeName()+"</h1>");
out.println("<h1>"+des.getNodeName()+"</h1>");
out.println("<h1>"+grandParent.getNodeName()+"</h1>");
out.println("<h1>"+link.getNodeName()+"</h1>");
I'm so desperate with these. I search and do it myself for my assignment and so so ... fresh about these DOM. I have also post 2 other thread about getParameter() to DOM to look up the traverse tree, but also desperate.
Plz help me, and tell me what to do.
Thx alot