0

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 objXml.LoadXml(pInfo.AsXml) Dim outerXML = Replace(objXml.OuterXml(), "<MID>someText</MID>", "<MID><![CDATA[<a href='https://www.google.com'>Click me</a>]]></MID>") 

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

<MID><a href='https://www.google.com'>Click me</a></MID> 

All it should display is:

<MID>Click me</MID> 

Any ideas why this is not working?

1 Answer 1

0

You can try like so with double quotes:

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

or

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

You could also use xml.WriteCdata with xml writer

https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmlwriter.writecdata?view=netframework-4.8

Sign up to request clarification or add additional context in comments.

3 Comments

Now it is still just displaying all the text like <MID><a href='google.com'>Click me</a></MID>
When you use triple quotes sets href="""google.com""", sorry I used double quote sets
I think what you are looking for has been answered here. stackoverflow.com/questions/706314/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.