Re: How to access/parse an associative/hashed array as responce using mozilla's SOAP client in javascript from the SOAPPropertyBag?
[email protected] Wed, 27 Jun 2007 09:55:06 +1000
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: > Hopefully somebody can tell me how to loop throug the returned array > items or object properties Given that you're using an rpc-style of exchange, you'll hopefully find a way to get at the associative array using the built-in decoding. But as a last resort you can always use xpath to grab what you need out of the soap xml response - something like the code below. Cheers - Leni. var doc = soapresponse.message; var query = "/soap:Envelope/soap:Body/ns1:getConfedJoinTreeResponse/ns1:return/ns1:item"; var resultType = XPathResult.ORDERED_NODE_ITERATOR_TYPE; var nsResolver = null; // you probably need a better nsResolver function, see: // http://developer.mozilla.org/en/docs/DOM:document.evaluate var result = doc.evaluate(query, doc, nsResolver, resultType, null); try { var node = result.iterateNext(); while (node) { // each <item> node has a <key> and <value> child // you can populate an associative array here } catch(e) { dump("exception:" + e); } }