logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: writing XML from a string: msg#00021

Subject: Re: writing XML from a string
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.

&lt;Child&gt;Test Content&lt;/Child&gt;

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




Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>