Re: [xml] parsing output from xmlNodeDump()



Daniel Veillard wrote:

On Wed, Sep 08, 2004 at 04:52:18PM -0400, Cory Virok wrote:
Hello all.

Is there a built in way to parse text that contains entity refs for XML markup without manually search-and-replacing entities? I need to reparse text that has been output by xmlNodeDump().

In my xml document I am storing xml subtrees as encrypted text within XML text nodes. My original XML doc looks like this:

<?xml ...?>
<root>
  <secret-stuff>
     <secret-xml>I'm gonna get encrypted!</secret-xml>
  </secret-stuff>
</root>

after encrypting the secret-xml content and making the secret-xml subtree a text node via xmlNodeDump() I get something like this:

<?xml ...?>
<root>
  <secret-stuff>
     &lt;secret-xml&gt;ENCRYPTED_TEXT&lt;/secret-xml&gt;
  </secret-stuff>
</root>

Now my question is... is there a built in way to parse the text node so that the entity refs are automagically recognized as XML markup? I realize I can just do the search and replace myself... but I'd like to use libXML to do this if I can.

 Seems to me you're mostly making the mistake of dumping <secret-xml>
itself and it subtree instead of dumping its *content* in the first place.
There is now (recently added) xmlParseInNodeContext() which I think
does what you want, but again it's needed only because you xmlNodeDump()
the wrong node !

Daniel

Thanks for the quick reply.

I wish I only had to dump out the content of the node. The hope is, that I can encrypt entire subtrees of a document and store this encrypted block as a text node for the subtree's parent. I guess I'll just go through the text by hand and search/replace the xml markup entities.

Cheers,
- Cory Virok



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]