xml minidom - get the full content of childnodes text
<p>I have a Test.xml file as:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;SetupConf&gt;
  &lt;LocSetup&gt;
    &lt;Src&gt;
      &lt;Dir1&gt;C:\User1\test1&lt;/Dir1&gt;
      &lt;Dir2&gt;C:\User2\log&lt;/Dir2&gt;
      &lt;Dir3&gt;D:\Users\Checkup&lt;/Dir3&gt;
      &lt;Dir4&gt;D:\Work1&lt;/Dir4&gt;
      &lt;Dir5&gt;E:\job1&lt;/Dir5&gt;       
    &lt;/Src&gt;
  &lt;/LocSetup&gt;
  &lt;/SetupConf&gt;
</code></pre>

<p>Where node depends on user input. In "Dir" node it may be 1,2,5,10 dir structure defined. As per requirement I am able to extract data from the Test.xml with help of @Padraic Cunningham using below Python code:</p>

<pre><code>from xml.dom import minidom
from StringIO import StringIO
dom = minidom.parse('Test.xml')
Src = dom.getElementsByTagName('Src')
output = ", ".join([a.childNodes[0].nodeValue for node in Src for a in  node.getElementsByTagName('Dir')])
print [output]
</code></pre>

<p>And getting the output: </p>

<pre><code>C:\User1\test1, C:\User2\log, D:\Users\Checkup, D:\Work1, E:\job1
</code></pre>

<p>But the expected output is:</p>

<pre><code>['C:\\User1\\test1', 'C:\\User2\\log', 'D:\\Users\\Checkup', 'D:\\Work1', 'E:\\job1']
</code></pre>

<p>Well it's solved by myself:</p>

<pre><code>from xml.dom import minidom
DOMTree = minidom.parse('Test0001.xml')
dom = DOMTree.documentElement
Src = dom.getElementsByTagName('Src')

for node in Src:

    output = [a.childNodes[0].nodeValue for a in node.getElementsByTagName('Dir')]

    print output
</code></pre>

<hr>

<p>And getting output:
[u'C:\User1\test1', u'C:\User2\log', u'D:\Users\Checkup', u'D:\Work1', u'E:\job1']</p>

<hr>

<p>I am sure there is more simple another way .. please let me know.. Thanks in adv.</p>

python xml