• 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
Accessing attributes of XML
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Accessing attributes of XML


  • Subject: Accessing attributes of XML
  • From: "Christian Graus" <email@hidden>
  • Date: Mon, 5 May 2008 22:34:24 +1000

Hi, I have the following code:

NSXMLDocument *doc = [[NSXMLDocument alloc] initWithContentsOfURL:xmlURL
options:0 error:&error];

        NSXMLNode *node = [doc rootElement];

NSArray *array = [node nodesForXPath:@"/DiaIndex/Item"

        error:&err];

        int nodeCount = 0;

 while(nodeCount < 1300)

{

NSXMLElement *node2  = [array objectAtIndex:nodeCount];

NSXMLElement *name = [node2 attributeForName:@"Name"];

                NSString * n = [name  stringValue];


                NSArray * attr = [node2 attributes];

                int count = [attr count];

                ++nodeCount;

        }



I cut out some code to simplify, if you spot an error that would stop it
compiling, that code is there.  I am getting the correct number of Item
nodes, but I cannot work out how to access the inner Text of the node ( I am
used to having the DOM to work with ), and when I search for an Attribute,
name does not appear to be null, but it's stringValue is.  The attributes
collection should be 15 odd objects, and it's 0.  Any help on how to search
and extract attribute values would be appreciated.


Thanks


Christian
_______________________________________________

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: Accessing attributes of XML
      • From: Jens Alfke <email@hidden>
  • Prev by Date: How to convert UInt8 array to NSString
  • Next by Date: Re: How to convert UInt8 array to NSString
  • Previous by thread: Re: How to convert UInt8 array to NSString
  • Next by thread: Re: Accessing attributes of XML
  • Index(es):
    • Date
    • Thread