[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GSXML
From: |
Nicola Pero |
Subject: |
Re: GSXML |
Date: |
Mon, 20 May 2002 14:54:56 +0100 (BST) |
> I have to say that in that case I don't know what on earth you are
> talking about.
My pleasure - try the following code -
#include <Foundation/Foundation.h>
#include <Foundation/GSXML.h>
/* Parse a NSString, returning the root node as parsed. */
GSXMLNode *rootNode (NSString *string)
{
NSData *data = [string dataUsingEncoding: NSUTF8StringEncoding];
GSXMLParser *parser = [GSXMLParser parser];
if ([parser parse: data] == NO)
{
NSLog (@"Couldn't parse");
return nil;
}
return [[parser doc] root];
}
int main (void)
{
CREATE_AUTORELEASE_POOL (pool);
/* The string we want to parse. */
NSString *string = @"<?xml version=\"1.0\"?><test></test>";
/* Parse the document and get the root node for later printing. */
GSXMLNode *root = rootNode (string);
/* Retain it because we need it later. */
RETAIN (root);
/* The GUI automatically recreates autorelease pools regularly,
* so let's simulate what happens in any running GUI program. */
DESTROY (pool);
pool = [NSAutoreleasePool new];
/* Now print out the details of the parsed root node. */
NSLog (@"Content is :");
NSLog ([root content]);
NSLog (@"Attributes are :");
NSLog ([[root propertiesAsDictionary] description]);
DESTROY (pool);
return 0;
}
If you have been able to use non-SAX GSXML for anything serious - you
lucky. I haven't.
- GSXML, Stefan Urbanek, 2002/05/19
- Re: GSXML, Marcus Müller, 2002/05/19
- Re: GSXML, Richard Frith-Macdonald, 2002/05/20
- Re: GSXML, Nicola Pero, 2002/05/20
- Re: GSXML, Richard Frith-Macdonald, 2002/05/20
- Re: GSXML, Nicola Pero, 2002/05/20
- Re: GSXML, Richard Frith-Macdonald, 2002/05/20
- Re: GSXML, Nicola Pero, 2002/05/20
- Re: GSXML, Nicola Pero, 2002/05/20
- Re: GSXML,
Nicola Pero <=
- Re: GSXML, Nicola Pero, 2002/05/20
- Re: GSXML, Richard Frith-Macdonald, 2002/05/21