| 54 |
|
} |
| 55 |
|
} |
| 56 |
|
|
| 57 |
+ |
void getAllXpathElements(const QString &xPathExpression, pugi::xml_document &doc, QList<pugi::xml_node> &result){ |
| 58 |
+ |
|
| 59 |
+ |
pugi::xpath_node_set selectedNodes; |
| 60 |
+ |
pugi::xpath_node node; |
| 61 |
+ |
|
| 62 |
+ |
try |
| 63 |
+ |
{ |
| 64 |
+ |
selectedNodes = doc.select_nodes(xPathExpression.toLatin1().constData()); |
| 65 |
+ |
} |
| 66 |
+ |
|
| 67 |
+ |
catch (const pugi::xpath_exception& e) |
| 68 |
+ |
{ |
| 69 |
+ |
displayErrorMessage("XPath element selection","Selection of elements using the XPathExpression: '" + xPathExpression + "' failed:\n" + e.what()); |
| 70 |
+ |
} |
| 71 |
+ |
|
| 72 |
+ |
for (pugi::xpath_node_set::const_iterator currNode = selectedNodes.begin(); currNode != selectedNodes.end(); ++currNode) |
| 73 |
+ |
{ |
| 74 |
+ |
node = *currNode; |
| 75 |
+ |
if(node){ // if node != null |
| 76 |
+ |
result << node.node(); |
| 77 |
+ |
} |
| 78 |
+ |
} |
| 79 |
+ |
|
| 80 |
+ |
if(result.isEmpty()){ |
| 81 |
+ |
result << pugi::xml_node(); // add an empty node if none found |
| 82 |
+ |
} |
| 83 |
+ |
|
| 84 |
+ |
} |
| 85 |
+ |
|
| 86 |
+ |
pugi::xml_node getFirstXpathElement(const QString &xPathExpression, pugi::xml_document &doc){ |
| 87 |
+ |
pugi::xpath_node selectedNode; |
| 88 |
+ |
|
| 89 |
+ |
try |
| 90 |
+ |
{ |
| 91 |
+ |
selectedNode = doc.select_single_node(xPathExpression.toLatin1().constData()); |
| 92 |
+ |
} |
| 93 |
+ |
|
| 94 |
+ |
catch (const pugi::xpath_exception& e) |
| 95 |
+ |
{ |
| 96 |
+ |
displayErrorMessage("XPath element selection","Selection of element using the XPathExpression: '" + xPathExpression + "' failed:\n" + e.what()); |
| 97 |
+ |
} |
| 98 |
+ |
|
| 99 |
+ |
return selectedNode.node(); |
| 100 |
+ |
} |
| 101 |
+ |
|
| 102 |
|
void getAllNamedElements(pugi::xml_node &node, QList<pugi::xml_node> &result, XmlFilter &filters){ |
| 103 |
|
for (pugi::xml_node_iterator currNode = node.begin(); currNode != node.end(); ++currNode) |
| 104 |
|
{ |
| 114 |
|
} |
| 115 |
|
} |
| 116 |
|
|
| 117 |
< |
pugi::xml_node getFirstNamedElements(pugi::xml_node &node, XmlFilter &filters){ |
| 117 |
> |
pugi::xml_node getFirstNamedElement(pugi::xml_node &node, XmlFilter &filters){ |
| 118 |
|
|
| 119 |
|
pugi::xml_node foundNode; |
| 120 |
|
|
| 126 |
|
return *currNode; |
| 127 |
|
} |
| 128 |
|
|
| 129 |
< |
foundNode=getFirstNamedElements(*currNode,filters); |
| 129 |
> |
foundNode=getFirstNamedElement(*currNode,filters); |
| 130 |
|
|
| 131 |
|
if(foundNode.type()!=pugi::node_null){ |
| 132 |
|
return foundNode; |