• 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: NSXML and element parsing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSXML and element parsing


  • Subject: Re: NSXML and element parsing
  • From: Justin McKillican <email@hidden>
  • Date: Wed, 21 Nov 2007 07:21:31 -0500

Well no replies regarding this, would anyone be able to push me in the right direction to parse a simple XML to get a single element from a certain child?


thanks, -justin


On Nov 18, 2007, at 7:30 AM, Justin McKillican wrote:

Hi,

I'm somewhat new to Cocoa and come from a basic Perl/C background. I'm trying to write a small application that will parse a very simple XML file, for now I have it reading the XML document and it can go through every child with a for loop, however I need to only get a single element and not the entire child.

I seem to be missing something because everything I've tried gives me unrecognized selectors.

For now here is my basic code that is simply looping and works:

NSXMLDocument *xmlDoc;
NSError *err=nil;

NSURL *furl = [NSURL URLWithString:[NSString stringWithFormat:@"http://rakis.net/~justin/printapp/output5.xml "]];
xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:furl options:NSXMLDocumentTidyXML error:&err];



if (!furl) { NSLog(@"Can't create a URL from path"); return; } int i, count = [[xmlDoc rootElement] childCount]; for (i=0; i < count; i++) { NSXMLNode *rootNode = [[xmlDoc rootElement] childAtIndex:i]; NSLog(@"%i - %@\n",i,[rootNode stringValue]); }

For testing purposes my XML file looks like this :

<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
	<Book>
		<Comment>amazing book</Comment>
		<Title>Book Title</Title>
		<Publisher>Me</Publisher>
	</Book>
	<Book>
		<Comment>bad book</Comment>
		<Title>Another Book</Title>
		<Publisher>Someon Else</Publisher>
	</Book>
</mysqldump>


TIA, -justin _______________________________________________

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

_______________________________________________

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: NSXML and element parsing
      • From: Felix Franz <email@hidden>
References: 
 >NSXML and element parsing (From: Justin McKillican <email@hidden>)

  • Prev by Date: Re: Plugins Utilizing Core Data NSManagedObjectContext
  • Next by Date: Re: Best way of identifying duplicate files in Cocoa
  • Previous by thread: NSXML and element parsing
  • Next by thread: Re: NSXML and element parsing
  • Index(es):
    • Date
    • Thread