Python XPath SyntaxError: invalid predicate

前端 未结 2 836
天涯浪人
天涯浪人 2021-01-11 17:44

i am trying to parse an xml like


    

       
       XBV

       

        
2条回答
  •  星月不相逢
    2021-01-11 18:10

    ElementTree's XPath support is limited. Use other library like lxml:

    import lxml.etree
    root = lxml.etree.parse('test.xml')
    
    path="./pages/page/paragraph[text()='GHF']"
    print root.xpath(path)
    

提交回复
热议问题