I have a pretty complicated XML document, that I want to parse. Here is a simplified version of that XML:
<file
    xmlns="http://www.namespace.co.il"
    Media="MetTTV"
    Date="2015-03-29"
    FileType="Consolidated"
    SchemaVersion="1.2">
    <H Id="1012532" W="2198.05">
        ///more tags
    </H>
    <H Id="623478" W="3215.05">
        ///more tags
    </H>
   etc.
</file>
I want to get access to the < H > tags in order to count them.
here is my code:
import import lxml.etree
tree=lxml.etree.parse(xml_file)
count=1 
for HH in tree.xpath('//H'):
   print count
   count=count+1
this code works fine if I delete the
xmlns="http://www.namespace.co.il"
line.
But if I don't - it doesn't print anything to the console.
I tried changing the loop in many combinations, like
for HH in tree.xpath('//{http://www.namespace.co.il}H'):
or with
ns={'nmsp':'http://www.namespace.co.il'}
for HH in tree.xpath('//nmsp:H', ns)
but nothing seems to be working.
 
    