I'm writing some convenience functions for my XML parser based on pugixml (http://pugixml.org/), and now I have the problem that I want to retrieve only XML nodes with a specific attribute name and value!
XML example:
<Readers>
<Reader measurement="..." type="Mighty">
<IP reader="1">192.168.1.10</Group>
<IP reader="2">192.168.1.25</Group>
<IP reader="3">192.168.1.30</Group>
<IP reader="4">192.168.1.50</Group>
</Reader>
<Reader measurement="..." type="Standard">
...
</Reader>
</Readers>
My try:
std::string GetNodeValue(std::string node, std::vector<std::pair<std::string,std::string>> &attributes)
{
pugi::xml_node xmlNode = m_xmlDoc.select_single_node(("//" + node).c_str()).node();
// get all attributes
pugi::xml_object_range<pugi::xml_attribute_iterator> nodeAttributes(xmlNode.attributes());
// logic to compare given attribute name:value pairs with parsed ones
// ...
}
Can someone help me or give me a hint?! (maybe with Lambda Expressions)
Aucun commentaire:
Enregistrer un commentaire