13
0
livetrax/libs/pbd/tests/xpath.cc
Hans Baier 376263d925 * added XPath support to pbd/xml++
git-svn-id: svn://localhost/ardour2/branches/3.0@3384 d708f5d6-7413-0410-9779-e7cbd77b26cf
2008-05-22 12:06:20 +00:00

27 lines
849 B
C++

#include "assert.h"
#include <iostream>
#include "pbd/xml++.h"
using namespace std;
int main()
{
XMLTree doc("./rosegardenpatchfile.xml");
XMLNode* root = doc.root();
// "//bank" gives as last element an empty element libxml bug????
XMLNodeList* result = root->find("//bank[@name]");
cerr << "Found " << result->size() << " banks" << endl;
assert(result->size() == 8);
int counter = 1;
for(XMLNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
assert((*i)->name() == "bank");
assert((*i)->property("name"));
cout << "Found bank number " << counter++ << " with name: " << (*i)->property("name")->value() << endl;
for(XMLNodeList::const_iterator j = (*i)->children().begin(); j != (*i)->children().end(); ++j) {
cout << "\t found program with name: " << (*j)->property("name")->value() << endl;
}
}
}