j'ai un fichier XML à analyser, qui, comme indiqué ci-dessousSAX: Récupération des balises HTML de XML
<feed>
<feed_id>12941450184d2315fa63d6358242</feed_id>
<content> <fieldset><table cellpadding='0' border='0' cellspacing='0' style="clear :both"><tr valign='top' ><td width='35' ><a href='http://mypage.rediff.com/android/32868898' class='space' onmousedown="return enc(this,'http://track.rediff.com/click?url=___http%3A%2F%2Fmypage.rediff.com%2Fandroid%2F32868898___&service=mypage_feeds&clientip=202.137.232.113&pos=0&feed_id=12941450184d2315fa63d6358242&prc_id=32868898&rowid=674061088')" ><div style='width:25px;height:25px;overflow:hidden;'><img src='http://socialimg04.rediff.com/image.php?uid=32868898&type=thumb' width='25' vspace='0' /></div></a></td> <td><span><a href='http://mypage.rediff.com/android/32868898' class="space" onmousedown="return enc(this,'http://track.rediff.com/click?url=___http%3A%2F%2Fmypage.rediff.com%2Fandroid%2F32868898___&service=mypage_feeds&clientip=202.137.232.113&pos=0&feed_id=12941450184d2315fa63d6358242&prc_id=32868898&rowid=674061088')" >Android </a> </span><span style='color:#000000 !important;'>testing</span><div class='divtext'></div></td></tr><tr><td height='5' ></td></tr></table></fieldset><br/></content>
<action>status updated</action>
</feed>
Tag contient le contenu HTML, qui contient les données dont j'ai besoin. J'utilise un analyseur SAX. Voici ce que je fais
private Timeline timeLine; //Object
private String tempStr;
public void characters(char[] ch, int start, int length)
throws SAXException {
tempStr = new String(ch, start, length);
}
public void endElement(String uri, String localName, String qName)
throws SAXException {
if (localName.equalsIgnoreCase("content")) {
if (timeLine != null) {
timeLine.setContent(tempStr);
}
}
Cette logique fonctionne-t-elle? Si non, comment puis-je extraire des données HTML incorporées à partir de XML en utilisant SAX Parser?
D'où proviennent 'timeLine' et' tempStr'? –
@ L'Elite Gentleman édité pour prendre en charge les variables req. –