lxml etree xmlparser remove unwanted namespace

前端 未结 4 2165
感动是毒
感动是毒 2020-11-29 00:04

I have an xml doc that I am trying to parse using Etree.lxml


  
1&
4条回答
  •  孤街浪徒
    2020-11-29 00:15

    The last solution from https://bitbucket.org/olauzanne/pyquery/issue/17 can help you to avoid namespaces with little effort

    apply xml.replace(' xmlns:', ' xmlnamespace:') to your xml before using pyquery so lxml will ignore namespaces

    In your case, try xml.replace(' xmlns="', ' xmlnamespace="'). However, you might need something more complex if the string is expected in the bodies as well.

提交回复
热议问题