Parse xml using xpath and java

前端 未结 1 1329
[愿得一人]
[愿得一人] 2021-01-20 15:42

Now I am want to parse xml which is coming from webservice. For parsing, I used xpath and java. I have the following code:

package test.client;

import com.s         


        
相关标签:
1条回答
  • 2021-01-20 16:22

    You need to set up namespaces on your XPath object. Use XPath.setNamespaceContext() to do this. Alternatively you could just use local names in your XPath expression, e.g. //*[local-name()='alarm-response-list']/*[local-name()='alarm-responses']/*[local-name()='alarm'] but the namespace option is better.

    A whole lot of information about using namespaces with XPath expressions is already in another answer here.

    0 讨论(0)
提交回复
热议问题