Re: Help Reading XML file
i have got this so far but it only reads the first level and doesnt go
any deeper.
DocumentBuilderFactory docBuilderFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (new File("configuration.xml"));
doc.getDocumentElement ().normalize ();
Node n;
NodeList nodes = doc.getDocumentElement().getChildNodes();
for( int i=0 ; i<nodes.getLength(); i++ )
{
n = nodes.item( i );
if( n.getNodeType() == Node.ELEMENT_NODE )
{
if( n.getNodeName().equals( "b" ) )
{
NamedNodeMap attrs = n.getAttributes();
String s = attrs.getNamedItem("name").getNodeValue();
String s2 =
attrs.getNamedItem("value").getNodeValue();
}
}
}
i am able to read the first bit, which is <b name="test0" value="0">
but how do i get to the next level .thanks.