Converting XML to HTML with JavaScript, syntax not working -
i want convert xml html can viewed in table. have far, cant work reason.
console shows error:
ns_error_dom_bad_uri: access restricted uri denied
line 17: connect.send(null);
html code:
<table id="home"> <script language="javascript"> var connect = new xmlhttprequest(); connect.open("get", "home.xml", false); connect.setrequestheader("content-type", "text/xml"); connect.send(null); var thedocument = connect.responsexml; var customers = thedocument.childnodes[0]; (var = 0; < customers.children.length; i++) { var customer = customers.children[i]; var stilling1 = customer.getelementsbytagname("stilling"); var arbeidssted1 = customer.getelementsbytagname("arberidssted"); var arbeidsgiver1 = customer.getelementsbytagname("arbeidsgiver"); var datoregistrert1 = customer.getelementsbytagname("datoregistrert"); var frist1 = customer.getelementsbytagname("frist"); document.write("<tr><td>"); document.write(stilling1[0].textcontent.tostring()); document.write("</td><td>"); document.write(arbeidssted1[0].textcontent.tostring()); document.write("</td><td>"); document.write(arbeidsgiver1[0].textcontent.tostring()); document.write("</td><td>"); document.write(datoregistrert1[0].textcontent.tostring()); document.write("</td><td>"); document.write(frist1[0].textcontent.tostring()); document.write("</td></tr>"); }
xml code:
<?xml version="1.0" encoding="utf-8"?>
<stilling>tekstilselger</stilling> <arbeidssted>bergen</arbeidssted> <arbeidsgiver>xxl</arbeidsgiver> <datoregistrert>23.09.2015</datoregistrert> <frist>06.10.2015</frist> <stilling>sushi chef</stilling> <arbeidssted>bergen</arbeidssted> <arbeidsgiver>zupperia matbørsen</arbeidsgiver> <datoregistrert>23.09.2015</datoregistrert> <frist>30.10.2015</frist> <stilling>psykolog</stilling> <arbeidssted>fjell</arbeidssted> <arbeidsgiver>haukeland universitetsykehus</arbeidsgiver> <datoregistrert>22.09.2015</datoregistrert> <frist>03.10.2015</frist> <stilling>butikkansvarlig</stilling> <arbeidssted>bergen</arbeidssted> <arbeidsgiver>spraytanhuset</arbeidsgiver> <datoregistrert>18.09.2015</datoregistrert> <frist>04.10.2015</frist>
i not sure if right way new javascript. changes/corrections need made in order work. of text in code in norwegian well.
Comments
Post a Comment