GSXMLParser 0.1 15 September, 2000 GSXMLParser GSXML.h

The XML parser object is the pivotal part of parsing an XML document - it will either build a tree representing the document, or will cooperate with a GSSAXHandler object to provide parsing without the overhead of building a tree.

parser: source

Creation of a new Parser by calling initWithSAXHandler:source:

Source must be NSString (file name), NSData (raw document contnets), NSURL (not yet implemented), or nil (for incremental parsing).

GSXMLParser *p = [GSXMLParser parser: @"macos.xml"]; if ([p parse]) { [[p doc] dump]; } else { printf("error parse file\n"); }
parserWithSAXHandler: handler source: source

Creation of a new Parser by calling initWithSAXHandler:source:

Source must be NSString (file name), NSData (raw document contnets), NSURL (not yet implemented), or nil (for incremental parsing).

If the handler object supplied is nil, the parser will build a tree representing the parsed file rather than attempting to get the handler to deal with the parsed elements and entities.

NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init]; GSSAXHandler *h = [GSDebugSAXHandler handler]; GSXMLParser *p = [GSXMLParser parserWithSAXHandler: h source: @"macos.xml"]; if ([p parse]) { printf("ok\n"); } [arp release];
xmlEncodingStringForStringEncoding: encoding Return the name of the string encoding (for XML) to use for the specified OpenStep encoding. initWithSAXHandler: handler source: source

Initialisation of a new Parser with SAX handler (if not nil).

The source object is intended to be any reasonable value, but for initial implementation may be an NSData object containing raw XML text, or the name of a file to parse.

In the future, it is intended that this method will also support NSYRL objects.

If the source object is nil then the parser will be initialised for incremental parsing.

If the handler object supplied is nil, the parser will build a tree representing the parsed file rather than attempting to get the handler to deal with the parsed elements and entities.

lib

Return pointer to xmlParserCtxt structure.

doc

Return GSXMLDocument object.

parse

Parse source. Return YES if parsed, otherwise NO. This method should be called once to parse the entiore document.

GSXMLParser *p = [GSXMLParser parser:@"macos.xml"]; if ([p parse]) { [[p doc] dump]; } else { printf("error parse file\n"); }
parse: data

Pass data to the parser for incremental parsing. This method should be called many times, with each call passing another block of data from the same document. After the whole of the document has been parsed, the method should be called with an empty or nil data object to indicate end of parsing. Once this has been done, the method may be used again to parse a new document.

GSXMLParser *p = [GSXMLParser parserWithSAXHandler: nil source: nil]; while ((data = getMoreData()) != nil) { if ([p parse: data] == NO) { NSLog(@"parse error"); } } // Do something with document parsed [p parse: nil]; // Ready to parse another document.
substituteEntites: yesno

Set and return the previous value for default entity support. Initially the parser always keep entity references instead of substituting entity values in the output.

keepBlanks: yesno

Set and return the previous value for default blanks text nodes support. ignorableWhitespace() are only generated when running the parser in validating mode and when the current element doesn't allow CDATA or mixed content.

getWarnings: yesno doValidityChecking: yesno

Sets whether the document needs to be validated.

errNo

Return error code.

setExternalEntityLoader function

Set a external entity loader.