• 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 Example Help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSXML Example Help


  • Subject: Re: NSXML Example Help
  • From: Robert Walker <email@hidden>
  • Date: Thu, 6 Apr 2006 12:04:26 -0400

I am working on a small project that needs to read a very simple XML / RSS file with a few simple items. I need to be able to step through them, and get the information out of the tags like the title description, etc.. I just can't find a simple example showing how to do this part. One section in the docs about Creating a Document Object From Existing XML is not working for me, so Traversing an XML Tree with nodes is not working either.

Can you give us a hint (maybe an error message) as to what you mean by "not working?" I'm using NSXMLDocument to read XML from my web services. I am using the NSXML classes to serialize/deserialize my custom objects within my SOAP calls.


After creating the NSXMLDocument object you should be able to use [myXML nextNode] and [myXML nextSibling] to traverse your document and extract any data you want.

Are you sure you have a well formed XML document to begin with? If you do then NSXMLDocument should be able to read it.

Here is a code snippet show how I'm reading my XML data:
...
...
...
// Call web service to authenticate user
id resultValue = [ProcessorService authenticateUser:[self username] in_password:[self password]];

if (resultValue != nil) {
// Create an NSXMLDocument
xmlDoc = [[[NSXMLDocument alloc] initWithXMLString:resultValue options:NSXMLDocumentTidyXML error:&err] autorelease];

// Get the root element
rootElement = [xmlDoc rootElement];

// Start processing from the first child node
objectNode = (NSXMLElement *)[rootElement nextNode];
...
...
...
}
...
...
...


On Apr 6, 2006, at 12:43 AM, ChrisB wrote:

I am very new to Cocoa / Obj-C development, but have been making good headway with Apple's documentation and a couple of books I have been working through. I am currently struggling with understanding the NSXML. I have worked through the "Tree-Based XML Programming Guide for Cocoa," and looked at the XMLBrowser example project. My problem is I am just not getting it from the example project. I need to find an example that is a little less involved and build on that, rather than start with such an evolved sample.

I am working on a small project that needs to read a very simple XML / RSS file with a few simple items. I need to be able to step through them, and get the information out of the tags like the title description, etc.. I just can't find a simple example showing how to do this part. One section in the docs about Creating a Document Object From Existing XML is not working for me, so Traversing an XML Tree with nodes is not working either.

It really is amazing how well these dev tools work, and how fun it is to write apps with OS X. Coming from only a VB, perl, and some PHP, I have made a lot of headway in such a short time.

Thanks for the input.

-- Robert Walker email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSXML Example Help
      • From: ChrisB <email@hidden>
References: 
 >NSXML Example Help (From: ChrisB <email@hidden>)

  • Prev by Date: NSCell with Embedded NSView
  • Next by Date: Re: NSCell with Embedded NSView
  • Previous by thread: NSXML Example Help
  • Next by thread: Re: NSXML Example Help
  • Index(es):
    • Date
    • Thread