mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-14 02:26:39 +01:00
* added XPath support to pbd/xml++
git-svn-id: svn://localhost/ardour2/branches/3.0@3384 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
975d410930
commit
376263d925
8 changed files with 837 additions and 112 deletions
26
libs/pbd/tests/xpath.cc
Normal file
26
libs/pbd/tests/xpath.cc
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue