如何在TinyXML2中将XMLElement转换为字符串 [英] How to convert an XMLElement to string in TinyXML2

查看:1270
本文介绍了如何在TinyXML2中将XMLElement转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在TinyXml 1中,可以使用<<<运算符,例如

In TinyXml 1 it was possible to convert a child element to a string using the << operator, e.g.

TiXmlElement * pxmlChild = pxmlParent->FirstChildElement( "child" );
std::stringstream ss;
ss << (*pxmlChild);

在TinyXml2中似乎无法实现.如何在TinyXml2中将元素转换为xml字符串?

This doesn't appear possible in TinyXml2. How do you convert an element to an xml string in TinyXml2?

编辑:具体来说,我在xml之后,例如如果xml是:

Specifically I'm after the xml, e.g. if the xml was:

<parent>
    <child>
        <value>abc</value>
    </child>
<parent>

我想要子元素的xml,例如

I want the xml for the child element, e.g.

<child>
    <value>abc</value>
</child>

推荐答案

来自TinyXml2社区:

From the TinyXml2 community:

(子节点的)打印是在实用程序功能中:

Printing (of a sub-node) is in a utility function:

XMLPrinter printer;
pxmlChild->Print( &printer );
ss << printer.CStr();

这篇关于如何在TinyXML2中将XMLElement转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆