0

I am trying to parse the following using Dom parser in Android.

<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>

For parsing I am using following code :

Node node = .....
String nodeName = node.getNodeName();
if (nodeName.equalsIgnoreCase("offerURL")) {
    String offerUrl = node.getFirstChild().getNodeValue()
    Log.d("offerUrl => " + offerUrl);
}

It works fine but the value of <offerURL> tag is getting truncated. The value of variable offerUrl printted in log cat is "http://statTest.dealtime.com/DealFrame/DealFrame.cmp?bm=553"

Not sure what exactly the issue is. Please help.

1 Answer 1

2

& is a predefined entitiy in XML and must be represented in a special way. In the URL, if you change all the & to &amp; that should work.

Predefined entities in XML will tell you all the predefined entities in XML and how to represent them.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Neeta for quick reply. I was previously using following code for parsing: document = documentBuilder.parse(inputStream); Then, I changed the parsing method to this: String responseString = convertStreamToString(responseStream); InputSource inputSource = new InputSource(new StringReader(responseString)); document = documentBuilder.parse(inputSource); using this technique the & were replaced with &amp; as you said. But still I am experiencing the same issue.
In the convertStreamToString method I used following statement: BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.