我将XML文件编成一个DOM物体。 但是,我遇到了一个问题,把 X(XML案卷)与以下格式混为一谈:
<Teaser><p>String Content Here</p></Teaser>
我对标签的源代码进行了观察。
<Teaser><p>String Content Here</p></Teaser>
我的守则如下:
NodeList teaserList = list.getElementsByTagName("Teaser");
teaserLen=teaserList.getLength();
String [] newsTeaser = new String[teaserLen];
for(int n2=0;n2<teaserLen;n2++){
newsTeaser[n2]=teaserList.item(n2).getFirstChild().getNodeValue();
}
But I am only getting "<" for each tag.
Because there is a pair <p></p>
inside <Teaser></Teaser>
, I wonder if android takes <p></p>
as another tag, so I try:
newsTeaser[n2]=teaserList.item(n2).getChildNodes().item(0).getFirstChild().getNodeValue();
But I am getting an error. So android is not taking <p></p>
as another tag.
Does anyone know what to do?? I would like to get all the text insider <Teaser>
, thus getting: <p>String Content Here</p>