Link to home
Start Free TrialLog in
Avatar of sherly
sherly

asked on

Writing a xml output with special character to a table

In my xml node, i have a node value with special character < and >
<MarkText><ASSY MARK></MarkText>

I can retrieve it using alert(MarkTextNodes.item(i).text);
However, when i try to write the output to a table :

strMarkObjectTable += "<table><tr><td>" + MarkTextNodes.item(i).text + "</tr></td></table>";
output.innerHTML=strMarkObjectTable;

It is giving me an empty table. Please help!
ASKER CERTIFIED SOLUTION
Avatar of Peter Kwan
Peter Kwan
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sherly
sherly

ASKER

is there an option to add in the check for "&" as well?
Yes, you can replace & with &amp;. But remember to add as the first replace, otherwise, the < and > does not work.

What I mean is the following:

var x =  MarkTextNodes.item(i).text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
Avatar of sherly

ASKER

Thank you so much!