Gregory Freeland wrote:
I've been using Xerces-C DOM and have run into an issue when writing to
an XML file. Basically, to write the XML file, I build up a
DOMDocument, adding nodes and such. Once the document is complete, the
DOMWriter is used to write the node to a file. I have cases though,
where I'll have a string containing XML characters, and several levels
of descendant nodes. Essentially, I want to write the string directly to
the file as a child node.
For example, the code snippet below will create a new DOM element, add
an attribute, and add a child text node. My problem occurs when the
XMLCh* variable "content" is a string that looks something like this:
"<Child>Test Content</Child>"
the resulting XML file will have the XML format characters translated.
<Child>Test Content</Child>
So is it possible to write the above XML string as a Text node, while
retaining the XML formatting?
You are confusing content with markup/structure. If you want to
serialize markup, create structure (elements and text nodes), not a
single text node.
You could also hack the serializer code, but then you are essentially
breaking the code to match your model, which is inherently broken.
Dave