Hello DaniWeb. Here is my problem. I have an XML file that is arranged like this..
<document>
<Word>apple</Word>
<Word>hat</Word>
<Word>car</Word>
</document>
I'm trying to figure out how to grab the actual words.
This is how I'm doing it now.
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(new File("data/general/words.xml"));
NodeList level = doc.getElementsByTagName("document");
NodeList list = doc.getElementsByTagName("Word");
for (int i = 0; i < list.getLength(); i++) {
System.out.println((Element)list.item(i));
}
But it doesn't work. The output it gives me is this:
[Word: null]
[Word: null]
[Word: null]
etc for each element.
So I think what is happening is that it thinks my XML is set up like
<Word name="Apple"/>
<Word name="Car"/>
So I guess my question is how do I grab the word when its inbetween tags instead of a property of a tag??