hervens 0 Newbie Poster

Hello, I have the current sample xml document below:

  <category name="Temp">
    <unit id="0">
      <fromFormula>inFrom0</fromFormula> <-- need this value
    <unit id="1">
  <category name="Length">
    <unit id="0">

Now, I am trying to retrieve the value "inFrom0" from the <fromFormula> element but Its not working
this is part of the code that I have so far

Element rootElement = document.getDocumentElement(); 
            System.out.println("works here" );
            Node temp = rootElement.getElementsByTagName("category").item(0); 
            System.out.println("works here1 " + temp.getNodeName() + temp.getAttributes().getNamedItem("name").getNodeValue() );
            Node id = temp.getChildNodes().item(0);

            System.out.println("works here2 " + id.getNodeName() ); // <--returns #text instead of element!
            Node txt = id.getChildNodes().item(0); // <-- execution stops here
            System.out.println("works here3 " + txt.getNodeName());
            String result = txt.getChildNodes().item(0).getNodeValue();
            System.out.println("node value is: " + txt);

For some reason, right after
<category name="Temp"> my code cannot seem to reach the next xml element., and instead only sees an empty text node

The results from all the System.out.println are as followed:
works here
works here1 categoryTemp
works here2 #text

Thank you
Any help is appreciated

Also, if it helps, i'm using java and the blackberry sdk api

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.