Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ can';t获取属性';解析xml时的名称和值_C++_Xml_Pugixml - Fatal编程技术网

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;