<cfscript> // Let's create some HTML that contains escaped HTML entities ( lt / gt ). ``` <cfsavecontent variable="htmlContent"> <p id="target"> I love the <main> tag! </p> </cfsavecontent> ``` // Using Lucee's native htmlParse() function, we can parse the HTML snippet into an // XML document. From there, we can locate the <p> node. // -- // NOTE: I am using "//*" because the produced XML document includes XML NameSpaces // that prevent me from search based on xmlName. paragraphNode = htmlParse( htmlContent ) .search( "//*[ @id = 'target' ]" ) .first() ; hrule = ( chr( 10 ) & "<hr />" & chr( 10 ) ); // Let's try to extract the original text-value of the Paragraph tag. echo( paragraphNode.xmlText ); echo( hrule ); echo( paragraphNode.xmlCData ); echo( hrule ); echo( paragraphNode.xmlNodes[ 1 ].xmlText ); echo( hrule ); echo( paragraphNode.search( "string( ./text() )" ) ); echo( hrule ); echo( encodeForHtml( paragraphNode.xmlNodes[ 1 ].xmlText ) ); echo( hrule ); echo( encodeForXml( paragraphNode.xmlNodes[ 1 ].xmlText ) ); echo( hrule ); echo( toString( paragraphNode.xmlNodes[ 1 ] ) ); echo( hrule ); echo( toString( paragraphNode.xmlNodes[ 1 ] ).listRest( ">" ) ); </cfscript>