Generate/get xpath from XML node java

前端 未结 8 830
清酒与你
清酒与你 2020-11-22 10:39

I\'m interested in advice/pseudocode code/explanation rather than actual implementation.

  • I\'d like to go trough xml document
8条回答
  •  猫巷女王i
    2020-11-22 11:19

    I have written a method to return the absolute path of an element in the Practical XML library. To give you an idea of how it works, here's an extract form one of the unit tests:

    assertEquals("/root/wargle[2]/zargle",
                 DomUtil.getAbsolutePath(child3a)); 
    

    So, you could recurse through the document, apply your tests, and use this to return the XPath. Or, what is probably better, is that you could use the XPath-based assertions from that same library.

提交回复
热议问题