C++ can';t获取属性';解析xml时的名称和值
我有一个非空的C++ can';t获取属性';解析xml时的名称和值,c++,xml,pugixml,C++,Xml,Pugixml,我有一个非空的pugi::xml\u节点my\u节点 如果我用my_node.print(std::cout)打印它我可以清楚地看到这个节点的内容是正常的。 比如说: <my_class id="0" name="my class" type="my type"> <child_1> 45.0 </child_1> <child_2> 0.01 </child_2> <child_3> 100.0 <
pugi::xml\u节点my\u节点代码>
如果我用my_node.print(std::cout)打印它代码>我可以清楚地看到这个节点的内容是正常的。
比如说:
<my_class id="0" name="my class" type="my type">
<child_1> 45.0 </child_1>
<child_2> 0.01 </child_2>
<child_3> 100.0 </child_3>
<child_4> some_string </child_4>
</my_class>
顺便提一下,我从文档中选取了这个例子,我不知道为什么会发生这种情况
我做错了什么?name()
和value()
方法返回const char\t*
char\u t
是Pugi特定的typedef,由PUGIXML\u WCHAR\u模式
宏控制
我认为发生了什么,您定义了PUGIXML\u WCHAR\u模式
,char\u t
变成了WCHAR\u t
,但是std::cout
不是Unicode。如果是这种情况,请尝试使用Unicode输出,如下所示:
std::wcout << attr.name() << L" : " << attr.value() << std::endl;
std::wcout
0x55727e049cd4 : 0x55727e049ce4
0x55727e049d1c : 0x55727e049d34
0x55727e049d8c : 0x55727e049da4
std::wcout << attr.name() << L" : " << attr.value() << std::endl;