I'm using KissXML on iOS to parse the XML data returned from a wcf REST web service (written in c#)
The trouble I have is that KissXML doesn't like the namespace in the XML data that I get from the web service.
In a trivial example the XML data I get looks like this:
<ArrayOfItem xmlns="http://schemas.datacontract.org/2004/07/DataUpdateService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Item>Test</Item></ArrayOfItem>
KissXML can't seem to use xpath to parse this XML
resultNodes = [xmlDoc nodesForXPath:@"//Item" error:&error];
If I remove the default namespace from the XML string - then it works fine.
<ArrayOfItem xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Item>Test</Item></ArrayOfItem>
So this XML is fine and using the objective-c above I get 1 object in my array (as expected).
So the question is: What should I be doing about this? I have control of both the service and the iOS app so I can either change the service to try to remove or change the namespace (pointers to how to do this appreciated), or I can rip it out of my string once I get the data to the phone.
Both of these options feel a bit like a hack - are there better options?
I would recommend changing the defaultOutgoingResponseFormat to Json, and handling it instead of xml.
Why? read here: http://www.json.org/xml.html
and also it will solve your problem :)