0

This is my Code....I replaced the String like title.replace("’s", "is") but this can't work fo r me..

 NodeList Mymessage = fstElement.getElementsByTagName("title");
                     Element messageelement = (Element)Mymessage.item(0);
                     if(messageelement.hasChildNodes())
                     {
                         String title = ((Node)messageelement).getFirstChild().getNodeValue();
                         String title1=title.replace("’s", "is");
                         bin.setTitle(title1);
                         Log.v("titlr",title1);
                     }
Mehul
  • 71
  • 4

1 Answers1

0

Rather than using getNodeValue() on the child node, use getTextContent() on the parent:

Element messageelement = (Element)Mymessage.item(0);
String title1=messageelement.getTextContent().replace("’s", "is");
if (title1.length() > 0) {
    bin.setTitle(title1);
    Log.v("titlr",title1);
}
Deepak Swami
  • 3,838
  • 1
  • 31
  • 46
Jules
  • 14,841
  • 9
  • 83
  • 130
  • What's the complete class name you're using? I assumed it was a w3c.dom.Element, which inherits from w3c.dom.Node, which has the method as described at http://developer.android.com/reference/org/w3c/dom/Node.html#getTextContent() – Jules Jul 22 '12 at 09:33