[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [xml] question again! --- nobody can help me?[questions about the SAX interface of libxml2]
- From: Daniel Veillard <veillard redhat com>
- To: Spirit <xrh nanjing-fnst com>
- Cc: xml gnome org
- Subject: Re: [xml] question again! --- nobody can help me?[questions about the SAX interface of libxml2]
- Date: Mon, 2 Jun 2003 04:37:51 -0400
On Mon, Jun 02, 2003 at 03:54:13PM +0800, Spirit wrote:
> Hi everyone,
> I am a new user of libxml library. Perfect as it really is, I think this library is very good. However,It's not a simple thing to make clear how to ues this library. Now, there are some basic questions about the SAX interface:
> Q1. I have an xml file named 'a.xml'. In order to parse this file with the sax interface, what I know is the following:
> a. defining my callback functions (such as startDocument, startElement,etc.)
> b. accounting a new variant of 'xmlSaxHandler' structure, and then set the my own callbace function into it
> c. calling ' xmlSAXUserParseFile' function with the sax handler and 'a.xml' file
> Basically, are the above steps right?
I do not suggest new users to use the SAX API, use the reader API instead
if you need to stream . Otherwise those steps looks right. See the testSAX.c
code in the source distribution, but again I do NOT recommend using SAX !
> Q2.If errors eccur during parsing file, how can I locate the error position?
> If some errors occur in 'a.xml', the libxml sax parser will call the callback function 'error',which I have set into the 'sax handler', to notify that error. How can I know the error position of the source document? I think I should user the document locator.
No look at the code in error.c e.g. xmlParserPrintFileContext()
ctxt->input has the informations.
> Q3. How can I deal with the entity?
If you deal with entities then I ABSOLUTELY not recomment using SAX !
http://xmlsoft.org/entities.html see the warning in red at the bottom of the
page.
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]