0

how to obtain data inside a CDATA section using Xpath from a XML. I have embedded a html code inside a CDATA section within an XML like shown below

<xml>
  <node1>
    <![CDATA[ <div id= "div1">Hi howdy</div> ]]>
  </node1>
</xml>

How can I access it directly from Xpath. I can get the text of node1 by using .//node1/text()

What is the correct Xpath for getting the contents inside the CDATA section as a html document.

arvin_v_s
  • 1,036
  • 1
  • 12
  • 18
  • Hi Quentin, I am not trying to create a html element dynamically.I want to pass a html to front end in CDATA section of an XML.Now i want to select the content inside the CDATA using XPath. I am looking for the XPath. – arvin_v_s Aug 01 '16 at 09:54
  • `//node1/text()` does select what you want. What do you mean you want it as a HTML *document*, it is just a page fragment. – meskobalazs Aug 01 '16 at 11:24
  • i didn't post the entire content here. this is an example.I want to again parse it. If i can make it into a document then i can parse it. – arvin_v_s Aug 01 '16 at 11:43
  • Anyway, `text()` does return the content of the CDATA section, so what is the problem? – meskobalazs Aug 01 '16 at 11:50

0 Answers0