• 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
A Simple NSXML XPath Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A Simple NSXML XPath Problem


  • Subject: A Simple NSXML XPath Problem
  • From: Bing Li <email@hidden>
  • Date: Sun, 29 May 2011 10:40:24 +0800

Dear all,

I got a problem when extracting data from XML using NSXML and XPath. When
doing the same thing using Java, it works fine. But using NSXML and XPath,
the result is different.

The XML is pretty simple.

    <?xml version="1.0" encoding="UTF-8"?>
    <addresses>
        <road>Orange ST</road>
        <apt>RM235</apt>
    </addresses>

The following code is use to extract the value of the road, "Orange ST". In
Java, the XPath is the same, i.e., /addresses/road.

    NSError *err = nil;
    NSArray *nodes = [xmlDoc nodesForXPath:@"/addresses/road" error:&err];
    for (int i = 0; i < [nodes count]; i ++)
    {
         NSLog(@"%@", [nodes objectAtIndex:i]);
    }

But the result is as follows, not "Orange ST".

    <road>Orange ST</road>

Thanks so much!
Bing
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: A Simple NSXML XPath Problem
      • From: "Stephen J. Butler" <email@hidden>
  • Prev by Date: Re: Seeding random() randomly
  • Next by Date: Re: A Simple NSXML XPath Problem
  • Previous by thread: Re: iOS programming (who does what to whom?)
  • Next by thread: Re: A Simple NSXML XPath Problem
  • Index(es):
    • Date
    • Thread