Namespace handling in Groovys XmlSlurper

后端 未结 2 1181
慢半拍i
慢半拍i 2020-12-31 11:51

The situation:

def str = \"\"\"
  
    sudo 
    make me a sandwich!<         


        
2条回答
  •  天命终不由人
    2020-12-31 12:20

    I know this was answered a while ago, but here's an alternative for anyone else facing the same issue. The XmlSlurper class has three constructors, a couple of which allow you to specify you want it to be namespace-aware.

    public XmlSlurper(boolean validating, boolean namespaceAware)
    

    Declare the slurper by calling new XmlSlurper(false, true). I hope this is useful to others.

提交回复
热议问题