On Sat, 2007-11-17 at 19:53 +0100, Javier Gálvez Guerrero wrote:
> Any guide points, references, links or examples would be so much
> appreciated.

Javier,

the easy way to begin with xerces is to study the examples in
xerces-c-src_2_8_0/samples. Maybe you want to begin with the DOM parser,
since you need less to do. Also,
http://xerces.apache.org/xerces-c/apiDocs/classes.html has always been a
good reference to me.

> ... That means how can I change the DOM tree as been said before? And
> how to serialize it?

You can create a DOMDocument in different ways. If you want to read an
existing file, you need a DOMBuilder object, e.g. created by
DOMImplementation::createDOMBuilder or
DOMImplementation::createLSParser. Then you can read (and parse) a file
using DOMBuilder::parseURI.

DOMDocument::getDocumentElement gives you the root element, representing
the root element in the file. You can then navigate and manipulate the
tree with the methods of DOMElement and DOMNode.

For serialization, you may want to 'pretty print' the tree with some
w/s-nodes and give it to a DOMWriter object, i.e. method writeToString.

> On the other side I know that using SAX I could override startElement
> and endElement
> methods in order to define what I want to do in the XML file parsing process
> but I don't know if this applies to DOM as well or (if not) which methods I
> must override or use.

DOM and SAX are 'different worlds'. I would not mix them up. DOM is best
for (small) xml files, SAX is better in streams or huge files.

HTH,
                        Axel

Reply via email to