Reading an xml file from java

Reapsy00

Member
Apr 12, 2005
116
0
0
Hi I'm trying to use DOM but don't really get it. So if I have some xml like this

<button> <---- this is a node ?
<name>ok</name> <--- this an element ? and a child node?
<default>true</default>
<clicked>false</clicked>
</button>

like for the element i can do myelement.getTagName() gives me name but how do i get whats in between the tags? i.e ok ( (node) myelement).getNodeValue() returns null :(

It all seems kind of confusing ...
 

statik213

Golden Member
Oct 31, 2004
1,654
0
0
I've only used JDOM to manip. XML and don't remember it too well. nut the stuff in between tags e.g. <tags>stuff</tags> is I think called the text in JDOM, see if there's a method to get the text of a node.
 

Reapsy00

Member
Apr 12, 2005
116
0
0
Ahh think I figured out where I was going wrong, the stuff is a child of tags. Got confused trying to follow example code I found on the web that is wrong. Will stick to Sun's tutorial's from now on.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
DOM = not nice for manual manipulation of xml!!

(That seems to be a small theme tonight :p) If you get it all figured out, cool, but if you don't like working with DOM, check out JDom, as suggested by statik213 or other high-level tools for xml manipulation.