views:

76

answers:

1

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 similar in this site... anyway :

So I have a XML file :

<marker>This is a test &amp; it&#039;s fun. &eacute;</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

+1  A: 

Your XML isn't well-formed, so you probably isn't reading it as xml but plain text

Through DOM, you'll get &amp; and &#039; correctly, but an error on &eacute; (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);
Rubens Farias
This is not my full XML file. I don't have an error while loading the file, I'm just not displaying it correctly in my form... And I need to know how to make the é => é to make it readable
Rock
so you're opening that file as XMLDOMDocument and no errors happens, right?
Rubens Farias