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?
Asked
Active
Viewed 319 times
4 Answers
2
Simple is a fantastic library for XML parsing, I guarantee it'll make your life a whole load easier :)

ns476
- 375
- 1
- 3
-
hmmmm... is this available in android ?? – Arun Abraham Feb 16 '11 at 13:28
-
Sure, there's a guide here: http://stackoverflow.com/questions/1334802/how-can-i-use-external-jars-in-an-android-project – ns476 Feb 16 '11 at 19:58
1
Use SAXParser instead. it work simply great

Rohit Sharma
- 13,787
- 8
- 57
- 72
-
Use of SAX parser would do nothing to skip text segments, so I don't know why you suggest it? – StaxMan Feb 17 '11 at 00:33
-
i never came across such issue though i had parsed enough content xml. – Rohit Sharma Feb 17 '11 at 05:23
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