Re: Counting Elements in an xml file



Ouray Viney wrote:
Hi All:

I am looking at writing a python script that will let me parse a
TestSuite xml file that contains n number of TestCases.

My goal is to be able to count the <TestCase> elements base on a key
value pair in the xml node.

Example

<Testcase execute="true" name="foobar">

I would like to be able to count the number of TestCases that contain
the "execute=true" but not the ones that contain "execute=false".


You might try the `count` function in the module here:

http://gflanagan.net/python/projects/python-rattlebag/elementfilter.html

The pseudo xpath would be something like:

/Testcase[@execute=="true"]

hth

G.

.