lxml_document not implementing lxml_node

returns root as xml_node instead
This commit is contained in:
d-led 2012-10-03 17:18:41 +02:00
parent c19c128c9f
commit 07944e48c6
2 changed files with 6 additions and 18 deletions

View File

@ -6,11 +6,11 @@ local res=doc:load_file [[..\..\scripts\pugilua\pugilua.vcxproj]]
print(res.description)
assert(res.valid)
local node=doc:child('Project')
local node=doc:root():child('Project')
assert(node.valid)
print(node.valid)
print(node.name)
local query1=doc:select_nodes('Project/PropertyGroup')
local query1=doc:root():select_nodes('Project/PropertyGroup')
local query2=node:select_nodes('PropertyGroup')
assert(query1)
assert(query2)

View File

@ -98,9 +98,7 @@ namespace pugi {
public:
RefCountedPtr<lxml_parse_result> load_file(char const* path);
RefCountedPtr<lxml_node> child(char const* name);
RefCountedPtr<lxpath_node_set> select_nodes(char const* query);
RefCountedPtr<lxml_node> lxml_document::root() const;
bool valid() const;
@ -201,17 +199,8 @@ namespace pugi {
return RefCountedPtr<lxml_parse_result>(new lxml_parse_result(doc.load_file(path)));
}
RefCountedPtr<lxml_node> lxml_document::child(char const* name) {
return RefCountedPtr<lxml_node>(new lxml_node(doc.child(name)));
}
RefCountedPtr<lxpath_node_set> lxml_document::select_nodes(char const* query) {
try {
return RefCountedPtr<lxpath_node_set>(new lxpath_node_set(doc.select_nodes(query)));
} catch (pugi::xpath_exception const& e) {
std::cerr<<"Error: "<<e.what()<<std::endl;
return RefCountedPtr<lxpath_node_set>(new lxpath_node_set());
}
RefCountedPtr<lxml_node> lxml_document::root() const {
return RefCountedPtr<lxml_node>(new lxml_node(pugi::xml_node(doc)));
}
bool lxml_document::valid() const {
@ -299,8 +288,7 @@ void register_pugilua (lua_State* L) {
.addConstructor<void (*)()>()
.addProperty("valid",&lxml_document::valid)
.addFunction("load_file",&lxml_document::load_file)
.addFunction("child",&lxml_document::child)
.addFunction("select_nodes",&lxml_document::select_nodes)
.addFunction("root",&lxml_document::root)
.endClass()
.beginClass<lxpath_node>("xpath_node")