iphone - Parsing SOAP result using TouchXML in iOS SDK (iPad) -
i'm working on ipad project using functions in webservice. handling webservice connection, data etc works find. i'm not able parse result soap using touchxml. getting nodes out of xml returns 0 length.
the output xml:
<?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns: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>
<logonresponse xmlns="http://coreservices.org/v1">
<logonresult>
<id>1c0e9ad0-a3be-4cd0-8f0d-0616a63a4e28</id>
<userid>2</userid>
<user>
<id>2
<name>beheerder
<emailaddress />
<culturename>nl-nl</culturename>
</user>
</logonresult>
</logonresponse>
</soap:body>
</soap:envelope>
parser code:
nsdata *adata = [[nsdata alloc] initwithbytes:[webdata mutablebytes]
length:[webdata length]]; nsstring *xmldata = [[nsstring alloc] initwithdata:adata
encoding:nsasciistringencoding]; nslog(@"%@", xmldata); [xmldata release]; cxmldocument *domuseridentity = [[[cxmldocument alloc] initwithdata:adata
options:0
error:nil]
autorelease]; [adata release]; nsarray *nodeslist = [domuseridentity nodesforxpath:@"//logonresult" error:nil]; // 0 length (cxmlelement *resultelement in nodeslist) { (int counter = 0; counter nsstring *elemname = [[resultelement childatindex:counter] name]; nsstring * elemvalue = [[[resultelement childatindex:counter]
stringvalue]
stringbytrimmingcharactersinset:
[nscharacterset whitespaceandnewlinecharacterset]]; [elemname release]; [elemvalue release]; } } [nodeslist release];
any idea did wrong?
thank's alot in advance.
inoel
try using nsxmldocument, should work cxmldocument. here docs: link
Comments
Post a Comment