R
RK
Perhaps I'm confused somwhere in my understanding, but I'm trying to
deal with some escaped text from an XML file which includes html markup
and it appears there are a couple of techniques for escape codes.
(I hope I can describe my issue here without having to worry about how
to escape it for display on this group!)
On the server-side I extract some text from an XML file, which includes
some style and content. The XML is simply:
<text> < b >Title< /b > Moby Dick </text>
This is ampersand escaped bold tags within the xml file. An XML parser
on server side reads it nicely and sends it to my javascript on the
client side.
The javascript uses the XML content from an XmlHttpRequest and needs to
stick it into a webpage with
txtmsg = mystuff.getElementsByTagName("text")[0].firstChild.nodeValue;
document.getElementById(thisline).innerHTML=txtmsg;
and of course it shows up in my browser as
<b>Title</b> Moby Dick
....instead of with the word 'title' in bold.
I discovered a Javascript unescape() function, but it doesn't seem to
work for me. It appears the companion function "escape()" in javascript
uses percentage-signs to do the escaping.
Is there some means to unescape the ampersand-based escapes in
javascript, so that I can insert HTML that will get interpreted by the
browser?
Thanks in advance for any suggestions,
Ross.
deal with some escaped text from an XML file which includes html markup
and it appears there are a couple of techniques for escape codes.
(I hope I can describe my issue here without having to worry about how
to escape it for display on this group!)
On the server-side I extract some text from an XML file, which includes
some style and content. The XML is simply:
<text> < b >Title< /b > Moby Dick </text>
This is ampersand escaped bold tags within the xml file. An XML parser
on server side reads it nicely and sends it to my javascript on the
client side.
The javascript uses the XML content from an XmlHttpRequest and needs to
stick it into a webpage with
txtmsg = mystuff.getElementsByTagName("text")[0].firstChild.nodeValue;
document.getElementById(thisline).innerHTML=txtmsg;
and of course it shows up in my browser as
<b>Title</b> Moby Dick
....instead of with the word 'title' in bold.
I discovered a Javascript unescape() function, but it doesn't seem to
work for me. It appears the companion function "escape()" in javascript
uses percentage-signs to do the escaping.
Is there some means to unescape the ampersand-based escapes in
javascript, so that I can insert HTML that will get interpreted by the
browser?
Thanks in advance for any suggestions,
Ross.