非常に単純な XML ファイルを解析しています。
<?xml version="1.0" encoding="utf-8"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with XML.</description>
</book>
</catalog>
そして、デフォルト設定、つまり parse<0>() を使用して解析すると、次のようになります。
ifstream file(xmlFile.c_str(), ifstream::in );
int length;
file.seekg (0, ios::end);
length = (int)file.tellg();
file.seekg (0, ios::beg);
char xmlBuf[ length + 1 ];
file.read( &xmlBuf[0], length );
xmlBuf[length] = '\0';
document.parse<0>(xmlBuf);
すべてのノードは正しい場所にあり、xml_node.value_size() または xml_node.name_size() を使用してクエリを実行すると正しい長さになりますが、実際には名前または値を文字列に取得したり、単に printf() を取得したりすると、多くの値が返されます。次のようなもの:
(........./.(..............-. <titlK.
他の誰かがこれに遭遇しましたか?