1
我有下面的示例XML:波科XML - 獲取節點內XML
<root>
<node id="1">
<value>test</value>
<value2>test2</value2>
</node>
<node id="2">
<value>test</value>
</node>
</root>
我怎樣才能得到一個的std :: string整個內部節點1 XML內容?
我已經試過如下:
Poco:XML:Node *node = xmlDocument->getNodeByPath("/root/node[1]");
Poco::XML::XMLString xstr = node->getPocoElement()->innerText;
string str = Poco::XML::fromXMLString(node->getPocoElement()->innerText);
,它會返回此:
test \n test2
我需要這樣的:
<node id="1">
<value>test</value>
<value2>test2</value2>
</node>
謝謝,它的工作原理。我不敢相信沒有這樣的方法已經成爲 - 它非常有用。 – Machinegon