Re: Counting Elements in an xml file
- From: Paul Boddie <paul@xxxxxxxxxxxxx>
- Date: Sat, 30 Aug 2008 11:17:23 -0700 (PDT)
On 30 Aug, 19:37, Ouray Viney <ovi...@xxxxxxxxx> wrote:
<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".
With XPath-capable libraries, it should be enough to execute an XPath
query on the document. For example:
import libxml2dom
d = libxml2dom.parse(filename)
number_of_cases = d.xpath("count(//Testcase[@execute='true'])")
This applies the XPath count function to all Testcase elements in the
document having an execute attribute with a value of 'true', thus
returning the number of matching elements.
Paul
.
- Follow-Ups:
- Re: Counting Elements in an xml file
- From: Ouray Viney
- Re: Counting Elements in an xml file
- Prev by Date: wholesale lacoste t-shirts (www.SNEAKERS-IN-CHINA.com)
- Next by Date: Relative imports and "import X as Y"
- Previous by thread: wholesale lacoste t-shirts (www.SNEAKERS-IN-CHINA.com)
- Next by thread: Re: Counting Elements in an xml file
- Index(es):
Relevant Pages
|