Note that there are some explanatory texts on larger screens.

plurals
  1. POFetching the values with Element Tree
    primarykey
    data
    text
    <p>I would like to fetch some values for a particular component. For example i would like to fetch only 2 values from the below output (i.e Component --> name: paristrain and Stat --> TimeoutValue: value). I was trying to do this with xpath but i am not able to get the desired output. Can you please help me in this.</p> <pre><code>from xml.etree import ElementTree with open('rejexstats.xml', 'rt') as f: tree = ElementTree.parse(f) for node in tree.iter(): print node.tag, node.attrib </code></pre> <p>This prints:</p> <pre><code>Statistics {} {http://www.rejex.com/stats}Server {'start': '2013-01-22T22:30:13.583', 'product': 'rejex', 'end': '2013-01-23T09:39:45.249', 'startup': '2013-01-22T22:30:13.583', 'name': 'localhost'} {http://www.rejex.com/statistics}Component {'subtype': 'Thread', 'type': 'Supplier', 'name': 'paristrain'} {http://www.rejex.com/statistics}Stat {'type': 'entry', 'name': 'TimeoutValue', 'value': '120'} {http://www.rejex.com/statistics}Stat {'type': 'entry', 'name': 'PendingRequests', 'value': '0'} {http://www.rejex.com/statistics}Stat {'type': 'entry', 'name': 'Session|0|SupplierTimeout', 'value': '0'} {http://www.rejex.com/statistics}Stat {'type': 'entry', 'name': 'Session|0|Errors', 'value': '0'} {http://www.rejex.com/statistics}Stat {'type': 'entry', 'name': 'Session|3|SupplierTimeout', 'value': '0'} {http://www.rejex.com/statistics}Stat {'type': 'entry', 'name': 'ApplyRulesErrors', 'value': '0'} </code></pre> <p>XML File</p> <pre><code>&lt;Statistics&gt; &lt;Server end="2013-02-14T07:06:35.533" name="localhost" product="regex" start="2013-02-13T22:30:12.982" startup="2013-02-13T22:30:12.982"&gt; &lt;Component name="paristrain" subtype="Thread" type="Supplier"&gt; &lt;Stat name="TimeoutValue" type="entry" value="120"/&gt; &lt;Stat name="PendingRequests" type="entry" value="0"/&gt; &lt;Stat name="Session|0|SupplierTimeout" type="entry" value="0"/&gt; &lt;Stat name="Session|0|Errors" type="entry" value="0"/&gt; &lt;Stat name="Session|3|SupplierTimeout" type="entry" value="0"/&gt; &lt;Stat name="ApplyRulesErrors" type="entry" value="0"/&gt; &lt;Stat name="LateResponses" type="entry" value="0"/&gt; &lt;Stat name="CacheTries" type="entry" value="0"/&gt; &lt;Stat name="Session|4|Errors" type="entry" value="0"/&gt; &lt;Stat name="MaxActiveThreads" type="entry" value="0"/&gt; &lt;Stat name="MaxPendingQueueSize" type="entry" value="10"/&gt; &lt;Stat name="ValidResponses" type="entry" value="0"/&gt; &lt;Stat name="TranslateResponses" type="entry" value="0"/&gt; </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.
    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