simple XML parsing problem

In the code below im trying to see what is in the text node for a bookmark. Instead of getting the contents of the node i get nothing. Help ?

- - - my XML document - - -

<?xml version="1.0"?>

<!DOCTYPE folder SYSTEM "bookmark.dtd">

<folder name="Travel Sites">

<folder name="Islands">

<bookmark title="Seychelles" url="seychelles.net">Fun in the sun</bookmark>

</folder>

<bookmark title="Kashmir" url="kashmir.com">Lakes</bookmark>

</folder>

- - - code snippet - - -

NodeList children = root.getChildNodes();

System.out.println("num child nodes: " + children.getLength());

for (int i = 0; i < children.getLength(); i++) {

if (children.item(i).getNodeType() == Node.TEXT_NODE) {

System.out.println("node contents: " + children.item(i).getNodeValue());

}

}

- - - output - - -

node contents:

node contents:

node contents:

[1052 byte] By [mtndood] at [2007-9-26 2:25:24]
# 1

Well, you're one level up. The root node of you document contains <folder name> nodes, none of which has text in it, so it displays correctly. get the children of a child of the root, and it'll be fine.

P.S. getNodeName() would show you what node you're actually on.

Good luck.

lk555 at 2007-6-29 9:36:26 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...