M
mk834tt
Low hour xml/javascript pilot here. At http://www.w3schools.com/xml/xml_to_html.asp
trying to get an xml file to render in ff2. The problem is table
cells display "value </td>". If I remove the end tag, "< /td>" from
document.write (see lines 9 and 10) the text is clean and the end tag
is placed properly. Does document.write() have some smarts? I am
assuming it does unless someone can spot my error. Thank you.
Here's the code of interest:
01 for (var i = 0; i < cd.length; i++) {
02 var title = cd.getElementsByTagName("TITLE")
[0].childNodes[0].nodeValue;
03 var artist = cd.getElementsByTagName("ARTIST")
[0].childNodes[0].nodeValue;
04 var country = cd.getElementsByTagName("COUNTRY")
[0].childNodes[0].nodeValue;
05 var company = cd.getElementsByTagName("COMPANY")
[0].childNodes[0].nodeValue;
06 var price = cd.getElementsByTagName("PRICE")
[0].childNodes[0].nodeValue;
07 var year = cd.getElementsByTagName("YEAR")
[0].childNodes[0].nodeValue;
08 document.write("<tr>");
09 // document.write("<td>" + title + " < /td>");
10 document.write("<td>" + title);
11 document.write("<td>" + artist + " < /td>");
12 document.write("<td>" + country + " < /td>");
13 document.write("<td>" + company + " < /td>");
14 document.write("<td>" + price + " < /td>");
15 document.write("<td>" + year + " < /td>");
16 document.write("< /tr>");
17 }
Here's the first part of the xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
trying to get an xml file to render in ff2. The problem is table
cells display "value </td>". If I remove the end tag, "< /td>" from
document.write (see lines 9 and 10) the text is clean and the end tag
is placed properly. Does document.write() have some smarts? I am
assuming it does unless someone can spot my error. Thank you.
Here's the code of interest:
01 for (var i = 0; i < cd.length; i++) {
02 var title = cd.getElementsByTagName("TITLE")
[0].childNodes[0].nodeValue;
03 var artist = cd.getElementsByTagName("ARTIST")
[0].childNodes[0].nodeValue;
04 var country = cd.getElementsByTagName("COUNTRY")
[0].childNodes[0].nodeValue;
05 var company = cd.getElementsByTagName("COMPANY")
[0].childNodes[0].nodeValue;
06 var price = cd.getElementsByTagName("PRICE")
[0].childNodes[0].nodeValue;
07 var year = cd.getElementsByTagName("YEAR")
[0].childNodes[0].nodeValue;
08 document.write("<tr>");
09 // document.write("<td>" + title + " < /td>");
10 document.write("<td>" + title);
11 document.write("<td>" + artist + " < /td>");
12 document.write("<td>" + country + " < /td>");
13 document.write("<td>" + company + " < /td>");
14 document.write("<td>" + price + " < /td>");
15 document.write("<td>" + year + " < /td>");
16 document.write("< /tr>");
17 }
Here's the first part of the xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>