Solution 1 :

You can try like so with double quotes:

Dim outerXml as String = Replace(objXml.OuterXml(), "<MID>someText</MID>", "<MID><![CDATA[<a href="""">Click me</a>]]></MID>")


Dim outerXml as String
outerXML = Replace(objXml.OuterXml(), "<MID>someText</MID>", "<MID><![CDATA[<a href="""">Click me</a>]]></MID>")

You could also use xml.WriteCdata with xml writer

Problem :

I am programming in VB. And currently displaying some XML on a Webpage.
I would like to display a clickable link. So I tried:

Dim objXml As System.Xml.XmlDocument = New System.Xml.XmlDocument
Dim outerXML = Replace(objXml.OuterXml(), "<MID>someText</MID>", "<MID><![CDATA[<a href=''>Click me</a>]]></MID>")

But it actually displays just all the text and does not format the html inside CDATA:

<MID><a href=''>Click me</a></MID>

All it should display is:

<MID>Click me</MID>

Any ideas why this is not working?


Comment posted by’>Click

Now it is still just displaying all the text like