printing to string -> node.text
This commit is contained in:
parent
3e8bdc9a22
commit
347ac65743
Binary file not shown.
Binary file not shown.
@ -28,4 +28,8 @@ for i=0,n-1 do
|
||||
print(a.name)
|
||||
a=a:next_attribute()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
----
|
||||
node=doc:root():child('Project')
|
||||
print(node.text)
|
||||
@ -5,6 +5,7 @@
|
||||
#include <RefCountedPtr.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace pugi {
|
||||
namespace lua {
|
||||
@ -158,6 +159,8 @@ namespace pugi {
|
||||
|
||||
RefCountedPtr<lxpath_node_set> select_nodes(char const* query) const;
|
||||
|
||||
std::string text() const;
|
||||
|
||||
//todo: text(), xml_tree_walker somehow
|
||||
|
||||
public: // non-lua interface
|
||||
@ -457,6 +460,12 @@ namespace pugi {
|
||||
}
|
||||
}
|
||||
|
||||
std::string lxml_node::text() const {
|
||||
std::stringstream ss;
|
||||
node.print(ss);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
///////////////////
|
||||
RefCountedPtr<lxml_parse_result> lxml_document::load_file(char const* path) {
|
||||
return RefCountedPtr<lxml_parse_result>(new lxml_parse_result(doc.load_file(path)));
|
||||
@ -546,6 +555,7 @@ void register_pugilua (lua_State* L) {
|
||||
.addProperty("value",&lxml_node::value)
|
||||
.addProperty("type",&lxml_node::type)
|
||||
.addProperty("path",&lxml_node::path)
|
||||
.addProperty("text",&lxml_node::text)
|
||||
.addFunction("child",&lxml_node::child)
|
||||
.addFunction("first_attribute",&lxml_node::first_attribute)
|
||||
.addFunction("last_attribute",&lxml_node::last_attribute)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user