Problem reading an XML file using Javascript

webmasterbeta

New Member
I have the following xml file

<?xml version="1.0" ?>
<products category="big items">

<item id="1">
<name ref="abc100">item 1</name>
<des>½€a description</des>
<longdes></longdes>
<price pounds="210.70">301.00</price>
<largeimg>someimage.jpg</largeimg>
<smallimg>anotherimage.jpg</smallimg>
<itemoptions></itemoptions>
</item>

</products>

and I am trying to read it using javascript to create a web page using the following code

currentNode = myxmlDoc.childNodes(i);

name = currentNode.childNodes(0).firstChild.text;
ref = currentNode.childNodes(0).getAttribute("ref");
shortdes = currentNode.childNodes(1).firstChild.text
longdes = '';
if(currentNode.childNodes(2).hasChildNodes()) {
longdes = currentNode.childNodes(2).firstChild.text;
} // end if
price = currentNode.childNodes(3).firstChild.text;
poundsprice = currentNode.childNodes(3).getAttribute("pounds");
largeimg = currentNode.childNodes(4).firstChild.text;
smallimg = currentNode.childNodes(5).firstChild.text;
itemoptions = '';
if(currentNode.childNodes(6).hasChildNodes()) {
itemoptions = currentNode.childNodes(6).firstChild.text;
} // end if

having read in the xmldoc using the code

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

function loadXML(xmlFile){

xmlDoc.async="false";
xmlDoc.onreadystatechange=verify;
xmlDoc.load(xmlFile);
myxmlDoc=xmlDoc.documentElement;
return myxmlDoc;
}

function verify() {
if (xmlDoc.readyState != 4){
return false;
}
}

myxmlfile = 'xmls/'+itemcategory+'.xml';

myxmlDoc = loadXML(myxmlfile);

The whole process works fine accept when I use ascii characters &#128 to &#159, all others work and display fine but those display on my web page as a square.

For example using the xml above &#189 would display fine but the euro symbol &#128 wouldn't it would appear as a square.

Hmmmm
 
Back
Top