Need some help in parsing this XML in J2ME platform

☆樱花仙子☆ 提交于 2019-12-17 20:50:05

问题


Below mentioned is my XML,

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelopexmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Response xmlns="http://tempuri.org/">
<Result>
    <mp_response>
        <data signature="something">
                  <outcome errorcode="0" errordescription="" errorsolution=""/>
                 something
</data>
</mp_response>
</Result>
</Response>
</soap:Body>
</soap:Envelope>

I wish to extract the "errorcode" from this XML. How I am suppose to do that ? Please help.


回答1:


If your target devices support SAX from JSR 172, you should go with this parser. It will reduce your app's final jar size (no libs imported). There is a good sample at http://www.developer.nokia.com/Community/Wiki/JSR_172:_XML_Parsing_Example It actually unmarshalls the XML into Java objects.

After you feel confident you may try my generic approach to unmarshalling in Java ME at http://smallandadaptive.blogspot.com.br/2010/11/xml-data-binding.html




回答2:


You can use http://kxml.sourceforge.net/ to parse XML messages.

Observation

The message above looks like a Soap response message. The suppose to be parse for you by your soap client?



来源:https://stackoverflow.com/questions/9890222/need-some-help-in-parsing-this-xml-in-j2me-platform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!