On Friday, 29 May 2015 09:21:01 UTC+10, Sayth Renshaw  wrote:
> Is there a way to specify to all attributes in xpath? Instead of directly Eg 
> //element/@attr
> 
> So that you could effectively loop and filter if an element had more than one 
> Attribute?
> 
> So items = tree.xpath(@all_attrs)
> 
> From lxml import etree 
> 
> Tree = etree.Xpath(//root)
> 
> For k, v in items:
>     Choose your k's
> 
> 
> Thanks for your time in advance
> Please forgive some formatting errors phone auto correct 
> Sayth

It appears this is the best answer

n [17]: with open('C:/Users/Sayth/Desktop/20150530RHIL0.xml', 'rb') as f:
   ....:     tree = etree.parse(f)
   ....:     for attrResult in tree.xpath('/meeting/race/@*'):
   ....:         print(attrResult.attrname)
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to