Python xml ElementTree from a string source?

前端 未结 4 413
猫巷女王i
猫巷女王i 2020-12-12 15:40

The ElementTree.parse reads from a file, how can I use this if I already have the XML data in a string?

Maybe I am missing something here, but there must be a way to

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-12 16:08

    You need the xml.etree.ElementTree.fromstring(text)

    from xml.etree.ElementTree import XML, fromstring
    myxml = fromstring(text)
    

提交回复
热议问题