简体   繁体   English

如何在Android的单个响应中解析XML和JSON数据

[英]How To parse XML and JSON data in single Response in Android

Can Any one help me to parse XML and JSON data response in Android. 谁能帮我解析Android中的XML和JSON数据响应。 From my web service i got following type of response. 从我的Web服务中,我得到以下响应类型。 i am bit confused as to how can i parse this data . 我对如何解析此数据感到有些困惑。 Due to low reputation i can't upload image of response. 由于信誉较低,我无法上传回复图片。 help me to parse in android. 帮助我在android中解析。 here is link of response 这是回应的链接

It looks like that's just XML wrapping JSON. 看起来这只是XML 包装 JSON。 So parse it as XML, then take the text content of the root element (the only element present) and then parse that as JSON. 因此,将其解析为XML,然后获取根元素(存在的唯一元素)的文本内容,然后将其解析为JSON。

Basically, just do one thing at a time and you'll be fine: treat the XML as "just XML" where you want the text content, and treat the JSON as "just JSON" - it's irrelevant that it was previously wrapped in XML. 基本上,一次只做一件事,就可以了:将XML视为需要文本内容的“公正XML”,将JSON视为“公正JSON”-以前包装在XML中无关紧要。

(You might also want to see if there's anything you can do to make the web service just return plain JSON. There's no reason to wrap it in XML like this...) (您可能还想看看是否有什么方法可以使Web服务仅返回纯JSON。没有理由像这样将其包装在XML中。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM