pugixml not loading file



I'm trying to load "tree.xml" which is in the same directory as loadfile.cpp which also has pugixml.cpp, pugixml.hpp, pugiconfig.hpp.



#include "pugixml.cpp"
#include <iostream>
using namespace std;

int main()
{
pugi::xml_document doc;

pugi::xml_parse_result result = doc.load_file("tree.xml");

if (doc.load_file("file.xml")){
cout << "success" << endl;
}else{
cout << "fail" << endl;
}

cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << endl;
}


and I get the result:



fail
Load result: No error, mesh name:


I'm following manual here: http://ift.tt/1trtp15 under "Loading Documnet".


the tree.xml document looks like this:



<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>


Why isn't the file loading? I can't figure out wha'ts wrong.


No comments:

Post a Comment