Android 解析xml时,请使用字符串中的字符';s";无法解析

Android 解析xml时,请使用字符串中的字符';s";无法解析,android,string,character-encoding,Android,String,Character Encoding,这是我的代码…我替换了类似title.replace(“'s”,“is”)的字符串,但这对我来说不起作用 NodeList Mymessage = fstElement.getElementsByTagName("title"); Element messageelement = (Element)Mymessage.item(0); if(messageelement.hasChildNodes())

这是我的代码…我替换了类似title.replace(“'s”,“is”)的字符串,但这对我来说不起作用

 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);
                     }

不要在子节点上使用
getNodeValue()
,而要在父节点上使用
getTextContent()

Element messageelement = (Element)Mymessage.item(0);
String title1=messageelement.getTextContent().replace("’s", "is");
if (title1.length() > 0) {
    bin.setTitle(title1);
    Log.v("titlr",title1);
}

在将其作为xml文档之前;以字符串形式inputstream检索它,然后替换该字符串中的“'s”。然后您可以将其作为xml文档。如果您遇到异常,请发布堆栈trace@Jules当解析字符串时,字符串实际上被破坏了,就像这是一个大事件一样!。。。我的日志猫中只显示“That”。您使用的完整类名是什么?我假设它是一个w3c.dom.Element,它继承自w3c.dom.Node,其方法如中所述