summaryrefslogtreecommitdiff
path: root/src/xml.cc
blob: 3863bdff335e3e42947a5705a0ddf9b688fdd923 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "xml.h"

XMLFile::XMLFile (string file, string root_id)
{
	xmlpp::DomParser parser;
	parser.parse_file (file);
	if (!parser) {
		throw XMLError ("could not parse XML");
	}

	_root = parser.get_document()->get_root_node ();
	if (_root->get_name() != root_id) {
		throw XMLError ("unrecognised root node");
	}
}

string
XMLFile::string_tag (string id)
{
	stringstream x;
	x << _root->get_name() << "/" << id;
	xmlpp::NodeSet n = _root->find (x.str ());
	if (n.empty ()) {
		throw XMLError ("missing XML tag");
	} else if (n.size() > 1) {
		throw XMLError ("duplicate XML tag");
	}

	xml::Node::NodeList c = n.front()->get_children ();
	if (c.empty() 
	    

	return n.front()->get_name ();
}