Is there a quick way by using xpath from lxml in Python to convert following xml to dictionary? Or any other efficient way?
<rec item="1">
<tag name="atr1">random text</tag>
<tag name="atr2">random text</tag>
..................................
</rec>
<rec item="2">
<tag name="atr1">random text2</tag>
<tag name="atr2">random text2</tag>
..................................
</rec>
<rec item="3">
<tag name="atr1">random text3</tag>
<tag name="atr2">random text3</tag>
..................................
</rec>
need dictionary like this, or other simillar:
dic = [
{
'attr1':'random text',
'attr2':'random text'
},
{
'attr1':'random text2',
'attr2':'random text2'
},
{
'attr1':'random text3',
'attr2':'random text3'
}
]