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.

4
  • 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. Commented Aug 1, 2016 at 9: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. Commented Aug 1, 2016 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. Commented Aug 1, 2016 at 11:43
  • Anyway, text() does return the content of the CDATA section, so what is the problem? Commented Aug 1, 2016 at 11:50

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.