0
我想在Android中使用Dom解析器解析以下内容。使用DOM解析器的Android XML解析问题
<offerURL>
http://statTest.dealtime.com/DealFrame/DealFrame.cmp?bm=553&BEFID=93767&aon=%5E1&MerchantID=434524&crawler_id=1909400&dealId=TCk4NTG97Aa3wSQgh2U3FQ%3D%3D&url=http%3A%2F%2Frover.ebay.com%2Frover%2F1%2F707-64686-24023-0%2F2%3Fipn%3Dpsmain%26icep_item_id%3D190622592957%26icep_vectorid%3D260601%26kwid%3D1%26mtid%3D637%26crlp%3D1_260601%26kw%3D%7Bquery%7D%26query%3D%7Bquery%7D%26linkin_id%3D%7Blinkin_id%7D%26sortbid%3D%7Bbidamount%7D%26fitem%3D190622592957%26mt_id%3D637&linkin_id=7000251&Issdt=120323134700&searchID=p2.77722a731149145f60fa&DealName=Samsung+B2100+Outdoor+In+Schwarz+%28black%29+Orig.+Neuware&dlprc=89.95&crn=&istrsmrc=1&isathrsl=0&AR=1&NG=3&NDP=6&PN=1&ST=7&DB=sdcprod&MT=phx-pkadu-intl-dc20&FPT=DSP&NDS=&NMS=&MRS=&PD=95929320&brnId=14863&IsFtr=0&IsSmart=0&DMT=&op=&CM=&DlLng=7&RR=1&cid=&semid1=&semid2=&IsLps=0&CC=0&SL=0&FS=1&code=&acode=538&category=&HasLink=&frameId=&ND=&MN=&PT=&prjID=&GR=&lnkId=&VK=
</offerURL>
为了解析我使用下面的代码:
Node node = .....
String nodeName = node.getNodeName();
if (nodeName.equalsIgnoreCase("offerURL")) {
String offerUrl = node.getFirstChild().getNodeValue()
Log.d("offerUrl => " + offerUrl);
}
它工作正常,但<offerURL>
变量的值是越来越截断。 以log cat打印的变量offerUrl的值为“http://statTest.dealtime.com/DealFrame/DealFrame.cmp?bm=553”
不确定究竟是什么问题。请帮忙。
谢谢Neeta快速回复。 我以前使用以下代码进行分析: 'document = documentBuilder.parse(inputStream);' 然后,我将解析方法更改为: 'String responseString = convertStreamToString(responseStream); InputSource inputSource = new InputSource(new StringReader(responseString)); document = documentBuilder.parse(inputSource);' 使用这种技术,'&'被替换为'&',正如你所说的。 但我仍然遇到同样的问题。 – 2012-03-23 18:48:24
在convertStreamToString方法中,我使用了以下语句: 'BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,“UTF-8”));' – 2012-03-23 18:49:13