Reading XML file and fetching its attributes value in Python

后端 未结 7 681
情歌与酒
情歌与酒 2020-12-03 15:56

I have this XML file:


  virtual bug
  66523dfdf555dfd
  
          


        
7条回答
  •  一向
    一向 (楼主)
    2020-12-03 16:38

    You can try parsing it with using (recover=True). you can do something like this.

    parser = etree.XMLParser(recover=True)
    tree = etree.parse('your xml file', parser)
    

    I used this recently and it worked for me, you can try and see but in case you need to do any more complecated xml data extractions, you can take a look at this code i wrote for some project handling complex xml data extractions.

提交回复
热议问题