0

I am using the suds.js library in Appcelerator to interact with a SOAP API. I've successfully sent a request and am looking for help parsing the response. I'd like to parse out the location name.

http://pastie.org/private/rqekjes8qwlzwypw100vwa

4

1 回答 1

0

我对 suds.js 了解不多,但 jQuery 可以相当轻松地解析您的 xml。

示例:http: //jsfiddle.net/UprDs/1/

JS

var myXML = '<?xml version="1.0" encoding="utf-8" ?><Response>    <Data>        <MobileDropDetail>            <MobileDropTypeCode>Test</MobileDropTypeCode>            <MobileDropID>1</MobileDropID>        </MobileDropDetail>        <Locations>            <L>                <ID>1376</ID>                <Name>Testing Location</Name>            </L>            <L>                <ID>1403</ID>                <Name>Other Testing Location</Name>            </L>            <L>                <ID>1471</ID>                <Name>New Testing Location</Name>            </L>            <L>                <ID>1475</ID>                <Name>Test Los Angeles</Name>            </L>        </Locations>        <Groups>            <G>                <ID>251</ID>                <Name>Mobile Test Region</Name>            </G>            <G>                <ID>252</ID>                <Name>Mobile Demo Region</Name>            </G>        </Groups>        <LocationGroupPairs>            <LG>                <LID>1376</LID>                <GID>251</GID>            </LG>            <LG>                <LID>1475</LID>                <GID>251</GID>            </LG>            <LG>                <LID>1403</LID>                <GID>252</GID>            </LG>            <LG>                <LID>1471</LID>                <GID>252</GID>            </LG>        </LocationGroupPairs>    </Data>    <Error>        <Message>Success</Message>        <ReturnCode>1</ReturnCode>    </Error></Response>';

alert($(myXML).find('Locations Name:eq(0)').html());​
于 2012-04-10T20:46:38.193 回答