Note that there are some explanatory texts on larger screens.

plurals
  1. POExtracting values from XML using Python
    primarykey
    data
    text
    <p>I have the following xml extracted from another xml file.</p> <pre><code>&lt;notifications&gt; &lt;notification name="ccmSmtp" oid="1.3.6.1" status="current"&gt; &lt;objects&gt; &lt;object module="callhome" name="ccmSmtp" /&gt; &lt;/objects&gt; &lt;description&gt;This is a description&lt;/description&gt; &lt;/notification&gt; &lt;notification name="ccmAlertGroup" oid="1.3.6.1" status="current"&gt; &lt;objects&gt; &lt;object module="callhome" name="callHome" /&gt; &lt;/objects&gt; &lt;description&gt;This is a description&lt;/description&gt; &lt;/notification&gt; &lt;notification name="ccmAlert" oid="1.3.6.1" status="current"&gt; &lt;objects&gt; &lt;object module="callhome" name="callHome" /&gt; &lt;/objects&gt; &lt;description&gt;This is a description&lt;/description&gt; &lt;/notification&gt; &lt;notification name="ccmSmtp" oid="1.3.6.1" status="current"&gt; &lt;objects&gt;&lt;/objects&gt; &lt;description&gt;This is a description&lt;/description&gt; &lt;/notification&gt; &lt;/notifications&gt; </code></pre> <p>I'm using the following Python code.</p> <pre><code>from xml.dom import minidom xmldoc = minidom.parse('example.xml') grammarNode = xmldoc.childNodes[2] notificationsNode = grammarNode.childNodes[9] print notificationsNode.toxml() </code></pre> <p>This python code gives the output of the xml which i have given above.</p> <p>I tried the following to get the attribute values</p> <pre><code>notificationlist = xmldoc.getElementsByTagName('notification') print notificationlist[0].toxml() notification1 = notificationlist[0] key = notification1.attributes.keys() </code></pre> <p>Using this I'm able to get only the values of the fist set of notification.</p> <p>How is that i can get all the values of the attributes and store it in separate variables?</p>
    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