Skip to main content
Inspiring
June 4, 2013
Question

XML to links in HTML

  • June 4, 2013
  • 1 reply
  • 1012 views

I'm reading in some XML generated by Access. A node looks something like this:

<desc>

<div>Here is &lt;a href='https://example.com'>a useful link&lt;/a&gt; for you.</div>

</desc>

And when i put that into my textfield I end up with:

Here is <a href='https://example.com'>a useful link</a> for you.

I would like to have the links actually be hot links that show up blue and clickable. I'm sure it is some simple thing that I'm just missing.

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
June 4, 2013

Here's a little exercise using your xml string that works for me...

var xmlStr:String = "<desc><div>Here is &lt;a href='https://example.com'>a useful link&lt;/a&gt; for you.</div></desc>";


var xml:XML = new XML(xmlStr);

txt.htmlText = xml.div[0].text();

RothrockAuthor
Inspiring
June 4, 2013

Thanks Ned.

I'll see if I can do something with that. Actually my xml nodes look more like this:

<title>Some title here</title>

<desc>

<div>Here is &lt;a href='https://example.com'>a useful link&lt;/a&gt; for you.</div>

<div>&nbsp</div>

<div>Here is &lt;a href='https://example2.com'>another useful link&lt;/a&gt; for you.</div>

<div>And maybe a paragraph or two with bullets and all</div>

<ul>

<li>Item 1</li>

<li>Item 2</li>

</ul>

</desc>

And so on. The links could appear in any part of those and there might be multiple links in a given node. Somehow I've got to find a way to do what you showed, but for all the content.

RothrockAuthor
Inspiring
June 4, 2013

Maybe something like

txt.htmlText = xml.children()[0].text();