【问题标题】:libxml2 convert a node and all it's contents to a raw xml stringlibxml2 将节点及其所有内容转换为原始 xml 字符串
【发布时间】:2012-06-13 16:35:58
【问题描述】:

我想将一个节点及其所有内容和子节点转换为字符串。

例如我有这个节点

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

我想要一个函数来翻译成字符串“str1” 字符串的内容是这样的:

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

这是与源 xml 文件中完全相同形状的原始节点内容。

【问题讨论】:

  • 请更正问题中的错误。相同的 xml 代码给出了两次,但没有所需的字符串。
  • 这不是错误-_-'
  • 我编辑了您的问题,以明确您想要原始 xml 内容。您的问题在这里得到了正确回答吗:libxml xmlNodePtr to raw xml string??很容易找到它:[libxml2] raw.

标签: c xml libxml2


【解决方案1】:

这可能会有所帮助:

xmlChar * xmlXPathCastNodeSetToString (xmlNodeSetPtr ns) 将节点集转换为其字符串值。

来自the documentation

【讨论】:

  • 我已经试过了。它只转换我示例中的内容,结果将是:“azerty\nqwerty”
猜你喜欢
  • 2013-03-20
  • 2011-08-28
  • 2014-07-08
  • 1970-01-01
  • 2013-06-23
  • 2011-12-18
  • 2011-10-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多