• 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: Felix Franz <email@hidden>
  • Date: Wed, 21 Nov 2007 13:45:36 +0100

On 21.11.2007, at 13:21, Justin McKillican wrote:

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?

try NSXMLDocument nodesForXPath:error: method, as described in <http://developer.apple.com/documentation/Cocoa/Conceptual/NSXML_Concepts/Articles/QueryingXML.html#//apple_ref/doc/uid/TP40001258 >. You supply an XPath expression and this method returns the matched nodes.


For example "//Book[2]/Title" would return the Title-node of the second book.

Cheers,


felix



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


References: 
 >NSXML and element parsing (From: Justin McKillican <email@hidden>)
 >Re: NSXML and element parsing (From: Justin McKillican <email@hidden>)

  • Prev by Date: Re: Writing optimized screeshot utility.
  • Next by Date: replacing NSViewAnimation with CoreAnimation
  • Previous by thread: Re: NSXML and element parsing
  • Next by thread: Restoring sort order to NSTableView
  • Index(es):
    • Date
    • Thread