Re: nodesForXPath - is this correct behaviour?
Re: nodesForXPath - is this correct behaviour?
- Subject: Re: nodesForXPath - is this correct behaviour?
- From: Ryan Homer <email@hidden>
- Date: Thu, 18 Jan 2007 20:34:48 -0500
I did some more testing with various XML documents and here's what I
came up with...
First of all, let's use the following XML:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:en="http://any.thing.com">
<soap:Body>
<en:FindMembershipResponse>
<name>Ryan</name>
</en:FindMembershipResponse >
</soap:Body>
</soap:Envelope>
Note I've created two namespaces, soap and en. The following XPath
queries return the expected results:
/soap:Envelope
/soap:Envelope/soap:Body
/soap:Envelope/soap:Body/en:FindMembershipResponse
Now, let's make a small change by adding an xmlns tag to the
en:FindMembershipResponse element.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:en="http://any.thing.com">
<soap:Body>
<en:FindMembershipResponse xmlns="http://some.thing.else">
<name>Ryan</name>
</en:FindMembershipResponse >
</soap:Body>
</soap:Envelope>
/soap:Envelope/soap:Body/en:FindMembershipResponse still returns the
expected results.
However, if we remove the en: namespace tag like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:en="http://any.thing.com">
<soap:Body>
<FindMembershipResponse xmlns="http://some.thing.else">
<name>Ryan</name>
<FindMembershipResponse >
</soap:Body>
</soap:Envelope>
/soap:Envelope/soap:Body/FindMembershipResponse DOES NOT return
anything unless we remove the "xmlns=..." after FindMembershipResponse
Is this how NSXMLDocument:nodesForXPath: is supposed to work? My
problem is that the XML document that I receive from a Microsoft
server has the format of my last example and I'm therefore unable to
properly query the document.
On 9-Jan-07, at 12:12 AM, Stephen Deken wrote:
<FindMembershipResponse xmlns="http://www.msn.com/webservices/
AddressBook">
</FindMembershipResponse>
Am I getting the syntax wrong? Any ideas? Thanks in advance.
While I don't profess to know how to solve it, the problem appears
to be the 'xmlns' attribute on this element. Without it, the query
works as expected.
I'd be interested to learn how to solve this one myself. Is it
only because the mentioned URI is a 404?
Stephen Deken
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden