Hello,

Just thought I'd share a little tip I figured out. Dalvik (the Android
Java VM) implements an older version of the w3c DOM specification,
which doesn't include the getTextContent() method for the Node (and
Element) class. This resulted in a compile time error "The method
getTextContent() is undefined for the type Element"

Here's a little snippet to grab the text from a Dom Node or Element:

StringBuffer buffer = new StringBuffer();
NodeList childList = e.getChildNodes();
for (int i = 0; i < childList.getLength(); i++) {
    Node child = childList.item(i);
    if (child.getNodeType() != Node.TEXT_NODE)
        continue; // skip non-text nodes
    buffer.append(child.getNodeValue());
}
return buffer.toString();

Casey

--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to