The DOM parser has some problems. See, for instance,
http://code.google.com/p/android/issues/detail?id=225&colspec=ID%20Type%20Version%20Security%20Status%20Owner%20Summary

You might try calling normalize() on the top document element. That's
supposed to merge adjacent text elements and eliminate empty text
elements. (In theory, you shouldn't have to do this on the results of
a straight parse--it's a way to fix things up when you muck with the
DOM tree procedurally--but it sounds from your description like the
parser is returning a non-normalized tree.)

To avoid cast errors, switch on the value of getNodeType() and cast
(or ignore) accordingly.

Ted Hopp


On Mar 30, 2:27 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi!
>
> I tried parsing an XML file which I had created through code. The file
> has lines seperated by System.getProperty("line.seperator",""). The
> DOM engine parses the files but when I try to access the elements, the
> code crashes giving cast errors. On quick inspection of the memory
> dump it seems DOM parser creates a textimp node for each '\n' inserted
> in the file. Is this a correct behavior. If yes, can you suggest a
> generic way to handle elements in a tree.
>
> Regards
> Nitin Khanna
> Assistant Manager
> Hughes Systique Corp
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to