2

I would like to convert a node and all it's content and children to a string.

for example I have this node

<node i="a">
  <child1>azerty</child1>
  <child2>qwerty</child2>
</node>

I would like to have function to translate to a string "str1" the content of the string will be like this:

<node i="a">
  <child1>azerty</child1>
  <child2>qwerty</child2>
</node>

That is the raw node contents in the exact shape it was in the source xml file.

Jarekczek
  • 7,456
  • 3
  • 46
  • 66
user655561
  • 659
  • 1
  • 9
  • 24
  • Please correct the mistake in the question. Same xml code is given twice, but no desired string. – Jarekczek Sep 18 '12 at 13:57
  • it is not a mistake -_-' – user655561 Oct 02 '12 at 23:58
  • I edited your question to make it clear that you want the raw xml contents. Is your question answered correctly here: [libxml xmlNodePtr to raw xml string?](http://stackoverflow.com/questions/8232094/libxml-xmlnodeptr-to-raw-xml-string)? It's easy to find it: `[libxml2] raw`. – Jarekczek Oct 04 '12 at 05:50

1 Answers1

1

this might help:

xmlChar * xmlXPathCastNodeSetToString (xmlNodeSetPtr ns) Converts a node-set to its string value.

from the documentation

eqzx
  • 5,323
  • 4
  • 37
  • 54