How do I retrieve element text inside CDATA markup via XPath?

后端 未结 5 1175
南旧
南旧 2020-11-27 19:55

Consider the following xml fragment:


   

How do I retrieve the

5条回答
  •  隐瞒了意图╮
    2020-11-27 20:34

    CDATA sections are just part of what in XPath is known as a text node or in the XML Infoset as "chunks of character information items".

    Obviously, your tool is wrong. Other tools, as the XPath Visualizer correctly highlight the text of the Name element when evaluating this XPath expression:

    /*/Name/text()
    

    One can also write a simple XSLT transformation:

    
     
    
      ""
    
    
    

    When this transformation is applied on the provided XML document:

    
        
    
    

    the correct result is produced:

      "SomeText"
    

提交回复
热议问题