我想做的是通过java解析xml。例如,我只想要每个标签中的一段文本。
xml 示例
<data>\nSome Text :\n\MY Spectre around me night and day. Some More: Like a wild beast
guards my way.</data>
<data>\nSome Text :\n\Cruelty has a human heart. Some More: And Jealousy a human face
</data>
到目前为止我有这个
NodeList ageList = firstItemElement.getElementsByTagName("data");
Element ageElement =(Element)ageList.item(0);
NodeList textAgeList = ageElement.getChildNodes();
out.write("Data : " + ((Node)textAgeList.item(0)).getNodeValue().trim());
我试图只得到“一些更多:.....”部分我不想要整个标签也我试图摆脱所有\n