[Expat-discuss] Using Expat to rewrite an XML file, can it be
Thu, 19 Sep 2002 18:18:43 +0200 (MEST)
On 19 Sep, Jean-Claude Gervais wrote:
> I'd like to write a front-end that would use Expat to read an XML file and
> present certain strings contained in the XML to the user for editing.
> The problem I'm having is that I must then rewrite the XML back out to a
> In order to do that, what would be a good usage of Expat?
As you describe your task, this is a thing out of scope for
expat alone. expat is 'only' a streaming XML parser. It reads the XML
data and provides the data throu handlers to the application. It
neither stores the data for you, nor has it capabilities, to write XML
Of course you could use expat as parser for your application. But you
need additional components on top of expat. You could write them from
the scratch, or - if your XML data is not that huge - just use a DOM
Implementation on top of expat. There are several DOM implementations
on top of expat avaliable, with C API, or for usage from tcl/tk,
python, or perl (and probably a lot of scripting languages more).
> Can Expat be used to do this, or would I need to develop my own parser?
You should definitely not try to implement your own XML parser. This
would be in almost all cases just a waste of effort. Pick one of the
avaliable parser, that fits your needs, and just build the application
layer on top of that parser.