Re: Getting started with XML and XMLParser
Re: Getting started with XML and XMLParser
- Subject: Re: Getting started with XML and XMLParser
- From: Michael Rothwell <email@hidden>
- Date: Sun, 9 Nov 2003 12:55:25 -0500
I've been using the libxml and libxslt libraries available at
http://xmlsoft.org/
They offer a pretty complete XML, Xpath and XSLT implementation, and
are easy to use. These days, I usually just run an xPath query against
the XML file in question, and get the results from that.
For example:
/
************************************************************************
*
* -(id)getShowName:
************************************************************************
*/
-(NSString *)getShowName:(int)show
{
NSString * ret;
char *t1, *t2, *t3;
NSString * xpath;
xpath = [NSString stringWithFormat:@"//show[%d]/title",show];
t1 = GetXPathNodeText(m_ReplayListDoc, [xpath cString]);
ret = [NSString stringWithFormat:@"%s", t1];
if (t1) free(t1);
return ret;
};
-Michael
On Nov 9, 2003, at 11:26 AM, Kurt Marek wrote:
>
I need to parse an XML file and I had previously written a cheesy hack
>
using a lot of NSScanner code to get through it. Now that XMLParser is
>
available I would like to use it to clean up my code and make things a
>
bit easier to read and undoubtedly more efficient.
>
>
I read through the class description, but can't quite figure out how
>
to actually extract the data I am after. The class I wrote previously
>
would just scan up to the beginning tag and then put the data into a
>
string until it reached the ending tag. This got a little messy when I
>
had to pull out repeating elements that were defined by the same set
>
of beginning and ending tags. I am assuming that this is something the
>
XMLParser class can do without difficulty.
>
>
I have figured out how to get my XML file into the parser, but I can't
>
see how to actually extract the data from between the tags. Could
>
someone point me in the right direction?
>
>
Thanks,
>
Kurt
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.