Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I extract all child nodes with a common text value
    primarykey
    data
    text
    <p>Given the following XML</p> <pre><code>&lt;Tests&gt; &lt;AutomatedTests&gt; &lt;TestName&gt;Test1&lt;/TestName&gt; &lt;FunctionalLibraries&gt; &lt;FunctionalLibrary&gt;CommonLib&lt;/FunctionalLibrary&gt; &lt;FunctionalLibrary&gt;AppTestLib&lt;/FunctionalLibrary&gt; &lt;FunctionalLibrary&gt;Test1Lib&lt;/FunctionalLibrary&gt; &lt;/FunctionalLibraries&gt; &lt;/AutomatedTests&gt; &lt;AutomatedTests&gt; &lt;TestName&gt;Test2&lt;/TestName&gt; &lt;FunctionalLibraries&gt; &lt;FunctionalLibrary&gt;CommonLib&lt;/FunctionalLibrary&gt; &lt;FunctionalLibrary&gt;AppTestLib&lt;/FunctionalLibrary&gt; &lt;FunctionalLibrary&gt;Test2Lib&lt;/FunctionalLibrary&gt; &lt;/FunctionalLibraries&gt; &lt;/AutomatedTests&gt; &lt;AutomatedTests&gt; &lt;TestName&gt;Test3&lt;/TestName&gt; &lt;FunctionalLibraries&gt; &lt;FunctionalLibrary&gt;CommonLib&lt;/FunctionalLibrary&gt; &lt;FunctionalLibrary&gt;Test3Lib&lt;/FunctionalLibrary&gt; &lt;/FunctionalLibraries&gt; &lt;/AutomatedTests&gt; &lt;/Tests&gt; </code></pre> <p>Using VBScript, how can I find all the /Tests/AutomatedTests/FunctionalLibraries nodes that are common to ALL the /Tests/AutomatedTests nodes.<br> Based on the above xml, the results should be...</p> <pre><code>&lt;CommonTestLibraries&gt; &lt;FunctionalLibrary&gt;CommonLib&lt;/FunctionalLibrary&gt; &lt;/CommonTestLibraries&gt; </code></pre> <p>Thanks</p> <p>Here is what I have, I am hoping there is a simpler way since I have to do this several times on the same file.</p> <pre><code>set tempDict = CreateObject("Scripting.Dictionary") set commonDict = CreateObject("Scripting.Dictionary") Set xmlDoc = CreateObject("Microsoft.XMLDOM") xmlDoc.Load(fileName) set testNodes = xmlDoc.SelectNodes("/Tests/AutomatedTests") isFirst = true for each testNode in testNodes set functionalLibraryNodes = testNode.SelectNodes("FunctionLibraries/FunctionLibrary") For Each functionalLibraryNode in functionalLibraryNodes If not tempDict.Exists(functionalLibraryNode.Text) Then tempDict.Add functionalLibraryNode.Text, functionalLibraryNode.Text End If Next If NOT isFirst Then for each item in commonDict if tempDict.Exists(item) = false Then commonDict.Remove item End If Next Else Set commonDict = tempDict isFirst = false End If Set tempDict = nothing Set tempDict = CreateObject("Scripting.Dictionary") Next </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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