TrudyD1474 Posted August 8, 2011 Share Posted August 8, 2011 I have read through the entire XML tutorial and am still confused. I think I pretty much understand how to deal with the XML once I get it, but I cant seem to read it. I am providing my code. I took the XML to HTML script example. I have changed the file name to the one I need to use. I have added a KEY and PASSWORD. In the coding below I have changed to KEY and PASSWORD. I don't know if I put those items in correctly. I have changed the writes to show two of the elements. I'm using an html extension. This is an XML file from John Deere containing all of our used equipment. I want to add this to one of our webpages. When I run this I expect to see a listing containing the two elements. But all I'm getting is a blank webpage. The second box included a sample of the xml I'm trying to access. This was provided to me from John Deere. <?xml version="1.0" encoding="UTF-8"?><html><body><script type="text/javascript">if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }[color="#FF0000"]xmlhttp.open("GET","http://www.machinefinder.com/dealer_families/9398/machine_feed.xml",false);xmlhttp.send("key=448a6970-ac&password=PSW");[/color]xmlDoc=xmlhttp.responseXML; document.write("<table border='1'>");var x=xmlDoc.getElementsByTagName("machine");for (i=0;i<x.length;i++) { document.write("<tr><td>"); document.write(x[i].getElementsByTagName("id")[0].childNodes[0].nodeValue); document.write("</td><td>"); document.write(x[i].getElementsByTagName("model")[0].childNodes[0].nodeValue); document.write("</td></tr>"); }document.write("</table>");</script></body></html> <?xml version="1.0" encoding="UTF-8"?><machines> <dealer_family_id>9398</dealer_family_id> <timestamp>2011-Aug-04 17:03:31 CDT</timestamp> <machine> <id>938672</id> <images> <image primary="true"> <filePointer>http://www.machinefinder.com/images/machines/72/938672/1244855_large_22518.jpg</filePointer> </image> <image> <filePointer>http://www.machinefinder.com/images/machines/72/938672/1244859_large_35747.jpg</filePointer> </image> </images> <options> <option> <label>Configuration</label> <value>Standard</value> </option> <option> <label>Operator's Station</label> <value>No Cab</value> </option> <option> <label>Front Axle or Drive System</label> <value>2WD</value> </option> <option> <label>Transmission</label> <value>Collarshift</value> </option> <option> <label>Speeds Forward</label> <value>9</value> </option> <option> <label>Speeds Reverse</label> <value>3</value> </option> <option> <label>Loader</label> <value>Yes</value> </option> <option> <label>Describe</label> <value>553 #13277</value> </option> <option> <label>Rear Tire Size</label> <value>13.6/-28</value> </option> <option> <label>Radials</label> <value>Bias</value> </option> <option> <label>Front Tire Size</label> <value>27/9.50-15</value> </option> <option> <label>Rear</label> <value>50</value> </option> <option> <label>Front</label> <value>50</value> </option> <option> <label>3 Point Hitch</label> <value>Standard</value> </option> <option> <label>PTO</label> <value>540</value> </option> <option> <label>SCVs</label> <value>2</value> </option> <option> <label>Engine Hours</label> <value>1750</value> </option> </options> <description>Loader is new with full factory warranty</description> <advertised_price> <amount>19900</amount> <currency>USD</currency> </advertised_price> <wholesale_price> <amount>19900</amount> <currency>USD</currency> </wholesale_price> <dealerId>070859</dealerId> <category>Tractors - Utility (40-100hp)</category> <manufacturer>John Deere</manufacturer> <model>5210 & Loader</model> <serialNumber>LV5210S320370</serialNumber> <operationHours>1750</operationHours> <modelYear>2000</modelYear> <isNew>false</isNew> <horsePower>45</horsePower> <vatPct></vatPct> <separatorHours></separatorHours> <createdTimestamp>2009-05-13 16:29:55 -0400</createdTimestamp> <modifiedTimestamp>2011-07-15 12:00:10 -0400</modifiedTimestamp> <stockNumber>May 2009</stockNumber> <locationNotes>Moses Lake</locationNotes> </machine> Link to comment Share on other sites More sharing options...
TrudyD1474 Posted August 8, 2011 Author Share Posted August 8, 2011 I have made the following change" xmlhttp.send("key=448a6970-a02e-012e-d5e6-005056be003c","password=Evergreen"); Now I get the following error (looks good to me): The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. --------------------------------------------------------------------------------A name contained an invalid character. Error processing resource 'http://www.evergreen-implement.com/JD-xml2.xml'. Line 20...for (i=0;i<x.length;i++)-------------------^ Link to comment Share on other sites More sharing options...
thescientist Posted September 13, 2011 Share Posted September 13, 2011 I would log x to see exactly what it is. seems like it's not an array, or what you are expecting. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.