Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>When the feed comes in, I want to filter <strong>each xml file</strong> by removing the nodes that are <strong>not in my array of xpath's</strong></p> </blockquote> <p><strong>Step1. Select all nodes that aren't selected by the given XPath expressions</strong></p> <p><strong>I guess that by "nodes" you mean elements. If so, this XPath expression</strong>:</p> <pre><code>//*[count(. | yourExpr1 | yourExpr2 ... | yourExprN) &gt; count(yourExpr1 | yourExpr2 ... | yourExprN) ] </code></pre> <p><strong>selects all elements in the XML document that aren't selected by any of your N XPath expressions</strong> <code>yourExpr1</code>, <code>yourExpr2</code>, ... , <code>yourExprN</code></p> <p>If by "nodes" you mean elements, text-nodes, processing-instruction-nodes (PIs), comment-nodes and attribute nodes, use this XPath expression to select all nodes not selected by your N XPath expressions:</p> <pre><code>(//node() | //*/@*) [count(. | yourExpr1 | yourExpr2 ... | yourExprN) &gt; count(yourExpr1 | yourExpr2 ... | yourExprN) ] </code></pre> <p><strong>Step2. Delete all nodes selected in Step1.</strong></p> <p>For each of the nodes selected in Step1 above, use: </p> <pre><code> node.ParentNode.RemoveChild(node); </code></pre> <p><strong>Explanation</strong>:</p> <ol> <li><p>The XPath union operator <code>|</code> produces the union of two node-sets. Therefore the expression <code>yourExpr1 | yourExpr2 ... | yourExprN</code> when applied on the XML document produces the set of all nodes that are selected by any of the N given XPath expressions.</p></li> <li><p>A node <code>$n</code> doesn't belong to a set of nodes <code>$ns</code> exactly when ...</p> <p><code>count($n | $ns) &gt; count($ns)</code></p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload