I came across situation where XML tag has HTML code that needs to be parsed in XSLT. Here is the XML sample:
<note>
<text><p>This is a paragraph.</p><p>This is another paragraph.</p></text>
</note>
I want the embedded paragraph elements to be stored in different variables.
This is a paragraph.
should be stored in one variable and This is another paragraph.
should be stored in another variable.
Can you please help?
Parsing XML documents with
parse-xml
https://www.w3.org/TR/xpath-functions/#func-parse-xml or XML fragments withparse-xml-fragment
https://www.w3.org/TR/xpath-functions/#func-parse-xml-fragment is supported in XSLT 3.0, in earlier versions you would have to rely on processor specific extension provided or implementable.Your escaped code looks like an XHTML fragment so it should be parseable with
parse-xml-fragment
as in https://xsltfiddle.liberty-development.net/bFDb2CQ which does