Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
Do queries on non-root nodes work? I pass a TiXmlElement pointer to an xpath_processor constructor and make queries and the results are as if the xpath_processor is acting on the entire document that the TiXmlElement belongs to and not on this individual element.
There have been two posts that included questions about this, but no answers.
TinyXPath should work fine with non-root elements.
Could you post a more specific code example of what is not working?
TiXmlElement *p_root_element = doc.RootElement();
TinyXPath::xpath_processor xpath_w(p_root_element, "/a/b"); //One
unsigned int number_of_nodes1 = xpath_w.u_compute_xpath_node_set();
TiXmlNode * t = xpath_w.XNp_get_xpath_node(0); //Two
TinyXPath::xpath_processor xpath_t(t, "/b/c");
unsigned int number_of_nodes2 = xpath_t.u_compute_xpath_node_set();
assert(number_of_nodes2 == 2); //I expect 2 and get 4
The first xpath expression is "/a/b" which as expected gives me two nodes. I pick the first node and apply the expression "/b/c" on it expecting to get two nodes. I instead get four nodes.
Posting this code made me realise that I hadn't changed my code and was still passing xml.c_str() to TiXmlDocument::Parse() even though I now am using TinyXPath compiled with STL support.
Ignore previous post. TiXmlDocument::Parse() doesn't accept an std::string
So...is this a bug? Is there a way I can work around it?