• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: nodesForXPath almost always returns no objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nodesForXPath almost always returns no objects


  • Subject: Re: nodesForXPath almost always returns no objects
  • From: Ryan Homer <email@hidden>
  • Date: Tue, 9 Jan 2007 17:04:16 -0500

Thanks for the information, Klaus.

Do you know what XPath query I could use to navigate the document? When I try the following, it returns no elements:

NSXMLNode *n = [xmldoc rootElement];
NSArray *a = [n nodesForXPath:@"//soap:Body/FindMembershipResponse" error:&error];


According to Stephen, the XPath query works without the xmlns parameter. Is there some change in the XPath query string to accommodate for this?

Ryan

On 9-Jan-07, at 3:27 PM, Klaus Backert wrote:


Am 09.01.2007 um 16:03 schrieb Ryan Homer:

<h:table xmlns:h="http://www.w3.org/TR/html4/";> <h:tr> <h:td>Apples</h:td> <h:td>Bananas</h:td> </h:tr> </h:table

So, they are defining a namespace called "h". In my example, it is:

<FindMembershipResponse xmlns="http://www.msn.com/webservices/ AddressBook">

Does anyone know the difference? If we're not defining a new namespace, why the xmlns tag?

Ryan

If the attribute is xmlns - and *not* xmlns: followed by an XML name -, then the namespace name in the attribute value is that of the default namespace in the scope to which the declaration is attached.


See <http://www.w3.org/TR/1999/REC-xml-names-19990114/>.

An example from this W3C recommendation:

<?xml version="1.0"?>
<!-- elements are in the HTML namespace, in this case by default -->
<html xmlns='http://www.w3.org/TR/REC-html40'>
  <head><title>Frobnostication</title></head>
  <body><p>Moved to
    <a href='http://frob.com'>here</a>.</p></body>
</html>

<FindMembershipResponse xmlns="http://www.msn.com/webservices/ AddressBook">
sets the default namespace name to <http://www.msn.com/webservices/ AddressBook> (angle brackets for readability only). Then all elements with no prefix within the content of the element FindMembershipResponse belong to this default namespace.


Klaus

_______________________________________________

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


  • Follow-Ups:
    • Re: nodesForXPath almost always returns no objects
      • From: Klaus Backert <email@hidden>
    • Re: nodesForXPath almost always returns no objects
      • From: Justin Anderson <email@hidden>
References: 
 >nodesForXPath almost always returns no objects (From: Ryan Homer <email@hidden>)
 >Re: nodesForXPath almost always returns no objects (From: Stephen Deken <email@hidden>)
 >Re: nodesForXPath almost always returns no objects (From: Ryan Homer <email@hidden>)
 >Re: nodesForXPath almost always returns no objects (From: Klaus Backert <email@hidden>)

  • Prev by Date: Re: Kosher use of textView:shouldChangeTextInRange:replacementString?
  • Next by Date: Scaleable Toolbar Items
  • Previous by thread: Re: nodesForXPath almost always returns no objects
  • Next by thread: Re: nodesForXPath almost always returns no objects
  • Index(es):
    • Date
    • Thread