There MUST be an easy way to do that! I didn't want to ask this question again if somebody already asked it but I couldn't find something simi开发者_如何转开发lar in this site... anyway :
So I have a XML file :
<marker>This is a test & it's fun. é</marker>
So when I read this XML file with Javascript, I want to put it in a text input of a form, but it comes out with the & amp; etc instead of :
This is a test & it's fun. é
I really don't understand why I'm having so much problem finding a way to show the text right... Don't we all have the same problem with XML??? Help me!! In PHP, this would be sooo easy :(
Thanks a bunch in advance
Your XML isn't well-formed, so you probably isn't reading it as xml but plain text
Through DOM, you'll get & and ' correctly, but an error on é (undefined character entity)
EDIT
Since you don't have problems opening that file as XMLDOMDocument, you should be able to run following code into your browser. Make sute to create a SPAN tag to display that text:
var text = xmldoc.selectSingleNode("//marker").text;
document.getElementsByTagName("SPAN")[0].innerHTML = text;
alert(text);
精彩评论