2

In a Nodelist.item[index].getChildNodes(), i am getting some junk values in between all the nodes like "#text", what could be the reason ? this is causing an error... Could anyone tell me any permanent fix for this.. is this some sort of namespace issue?

Arun Abraham
  • 4,011
  • 14
  • 54
  • 75

4 Answers4

2

Simple is a fantastic library for XML parsing, I guarantee it'll make your life a whole load easier :)

ns476
  • 375
  • 1
  • 3
1

Use SAXParser instead. it work simply great

http://java-samples.com/showtutorial.php?tutorialid=152

Rohit Sharma
  • 13,787
  • 8
  • 57
  • 72
0

Try casting to Element the Node:

((Element)Nodelist.item[index]).getChildNodes().item(0).getNodeValue()

This would retrieve a the desired string.

Nacho L.
  • 9,582
  • 2
  • 25
  • 25
  • hmmmm....my problem is getting extra nodes populated in the doc for certain versions of android only...greater than 2.0 – Arun Abraham Feb 16 '11 at 13:26
0

Most likely that is white space someone uses indentation. It is not junk -- it is content like anything else, from XML parser's point of view.

But aside from this, if your code errors out due to this, your code is buggy. If you only want to access Elements, get just elements, or check type. You really should not assume things that are not necessarily true.

StaxMan
  • 113,358
  • 34
  • 211
  • 239