1

My problem is simple. I have a XercesDOMParser, so I can access through getDocument() to the DOMDocument stored in it.

I want to get the xml string representing the tree.

What is the correct call? I assume a valid operator/function is provided by the library.

Andry
  • 16,172
  • 27
  • 138
  • 246

1 Answers1

1

It's some time since I used Xerces-C but I would look at http://xerces.apache.org/xerces-c/apiDocs-2/classDOMWriter.html This takes care of the encoding and other problems (which are easy to overlook).

I'd look first at

virtual XMLCh *     writeToString (const DOMNode &nodeToWrite)=0
    Serialize the specified node as described above in the description of DOMWriter.
peter.murray.rust
  • 37,407
  • 44
  • 153
  • 217
  • Thank you... I was roaming in the doc without a good direction... guess you're the light I was waiting for :) – Andry Jan 13 '11 at 22:29
  • 2
    Thanks - I was heavily involved in the development of XML. Xerces is a very heavily engineered tool (including the W3C DOM spec which I think owes too much to Corba and not enough to simplicitly). So in Java I don't use Xerces directly but use XOM and find it much more productive. You might want to investigate simpler DOMs - it's a personal choice – peter.murray.rust Jan 13 '11 at 22:38
  • Well... Xerces has pros and cons... in particular it is, as you said, a very engineered tool. Not very easy to understand at the beginning, but later very useful. It is not fast when parsing... If speed and performance are required, it is better a less perfect parser like RapidXml but this one is very very very bad when programming complex applications... all contructors are private, there is no possibility to take your DOM from a point to another... difficult to manage insertion of new nodes an so on... – Andry Jan 13 '11 at 23:11
  • 1
    However... The code you showed is from version 2 of Xerces-C... Xerces-C 3 uses another object called DOMLSSerializer... It keeps many of the functionalities of DOMWriter... :) – Andry Jan 14 '11 at 08:16
  • @Andry thanks. It is often difficult to keep up with Xerces versions – peter.murray.rust Jan 14 '11 at 20:09