You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by alexsandrovp <al...@netscape.net> on 2008/07/25 22:57:25 UTC

how to make a comment?

Hi all,

I'm new to xerces and I'm using DOM in my current project.
I already know how to parse the xml file and get pointers to DOMNode objects
of my interest.

What I would like to learn is how can I comment out a particular node. Is
there a way to change the node type from ELEMENT_NODE to COMMENT_NODE? How
is the proper way to do it?

Thanks in advance.
-- 
View this message in context: http://www.nabble.com/how-to-make-a-comment--tp18659473p18659473.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: how to make a comment?

Posted by Alberto Massari <am...@datadirect.com>.
alexsandrovp wrote:
> Hi all,
>
> I'm new to xerces and I'm using DOM in my current project.
> I already know how to parse the xml file and get pointers to DOMNode objects
> of my interest.
>
> What I would like to learn is how can I comment out a particular node. Is
> there a way to change the node type from ELEMENT_NODE to COMMENT_NODE? How
> is the proper way to do it?
>
> Thanks in advance.
>   

There is no way in DOM to change the type of a node; you need to 
serialize the element using DOMWriter::writeToString (you may need to 
call setFeature(XMLUni::fgDOMXMLDeclaration, false) to turn off the 
generation of the XML PI), then create a DOMComment with the returned 
string, then use DOMNode::replaceChild to switch the two nodes.

Alberto

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org