2012-10-02 00:42:05 +04:00
|
|
|
assert(require 'pugilua')
|
|
|
|
|
|
2012-10-03 23:07:07 +04:00
|
|
|
print(pugi.version)
|
|
|
|
|
|
2012-10-02 00:42:05 +04:00
|
|
|
local doc=pugi.xml_document()
|
|
|
|
|
os.execute("cd")
|
2012-10-02 01:36:48 +04:00
|
|
|
local res=doc:load_file [[..\..\scripts\pugilua\pugilua.vcxproj]]
|
|
|
|
|
print(res.description)
|
2012-10-02 08:49:35 +04:00
|
|
|
assert(res.valid)
|
2012-10-02 01:36:48 +04:00
|
|
|
|
2012-10-03 19:18:41 +04:00
|
|
|
local node=doc:root():child('Project')
|
2012-10-02 01:36:48 +04:00
|
|
|
assert(node.valid)
|
|
|
|
|
print(node.valid)
|
2012-10-02 22:20:53 +04:00
|
|
|
print(node.name)
|
2012-10-03 19:18:41 +04:00
|
|
|
local query1=doc:root():select_nodes('Project/PropertyGroup')
|
2012-10-02 22:20:53 +04:00
|
|
|
local query2=node:select_nodes('PropertyGroup')
|
|
|
|
|
assert(query1)
|
|
|
|
|
assert(query2)
|
2012-10-03 14:58:34 +04:00
|
|
|
print(query1.type,pugi.xpath_node_set.type_sorted)
|
|
|
|
|
query1:sort(true)
|
|
|
|
|
print(query1.type,pugi.xpath_node_set.type_sorted)
|
|
|
|
|
print(query1.size,query2.size)
|
|
|
|
|
n=query1.size
|
|
|
|
|
for i=0,n-1 do
|
2012-10-03 15:28:37 +04:00
|
|
|
local node=query1:get(i):node()
|
|
|
|
|
local attribute=query1:get(i):attribute()
|
2012-10-03 21:11:09 +04:00
|
|
|
print(node.valid,node.path,attribute.valid)
|
2012-10-03 19:46:10 +04:00
|
|
|
local a=node:first_attribute()
|
|
|
|
|
while a.valid do
|
2012-10-03 20:02:49 +04:00
|
|
|
print(a.name)
|
2012-10-03 19:46:10 +04:00
|
|
|
a=a:next_attribute()
|
|
|
|
|
end
|
2012-10-03 21:14:08 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
----
|
|
|
|
|
node=doc:root():child('Project')
|
|
|
|
|
print(node.text)
|