Etsi tuesta

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Trouble getting XML to display

  • 2 vastausta
  • 2 henkilöllä on sama ongelma
  • 126 näyttöä
  • Viimeisin kirjoittaja kunoichisama

more options

I've built a site that pulls in XML data from a file to display in an area on the page. I know the code was working correctly because it has and will display properly in previous versions of FF and other browsers. When I first was building this, I had a lower version of FF and could see the XML display fine. I recall older FF asking me once if it was ok to load the data. Now, I don't have that option. Have I done something wrong, or is this a security settings issue?

Here's the html Ref code, if it helps:

<script type="text/javascript">var xmlDoc=null;if (window.ActiveXObject){// code for IExmlDoc=new ActiveXObject("Microsoft.XMLDOM");}else if (document.implementation.createDocument){// code for Mozilla, Firefox, Opera, etc.xmlDoc=document.implementation.createDocument("","",null);}else{alert('Your browser cannot handle this script');}if (xmlDoc!=null){xmlDoc.async=false;xmlDoc.load("articles.xml");document.write("<p id=xml_index_p>");var x=xmlDoc.getElementsByTagName("ARTICLE");for (i=0;i<x.length;i++){document.write("<h2 id=xml_h2>");document.write(x[i].getElementsByTagName("TITLE1")[0].childNodes[0].nodeValue);document.write("</h2>");document.write("<p id=xml_index_p>");document.write(x[i].getElementsByTagName("SUM1")[0].childNodes[0].nodeValue);document.write("</p>");}document.write("</p>");}</script>
I've built a site that pulls in XML data from a file to display in an area on the page. I know the code was working correctly because it has and will display properly in previous versions of FF and other browsers. When I first was building this, I had a lower version of FF and could see the XML display fine. I recall older FF asking me once if it was ok to load the data. Now, I don't have that option. Have I done something wrong, or is this a security settings issue? Here's the html Ref code, if it helps: <pre><nowiki><script type="text/javascript">var xmlDoc=null;if (window.ActiveXObject){// code for IExmlDoc=new ActiveXObject("Microsoft.XMLDOM");}else if (document.implementation.createDocument){// code for Mozilla, Firefox, Opera, etc.xmlDoc=document.implementation.createDocument("","",null);}else{alert('Your browser cannot handle this script');}if (xmlDoc!=null){xmlDoc.async=false;xmlDoc.load("articles.xml");document.write("<p id=xml_index_p>");var x=xmlDoc.getElementsByTagName("ARTICLE");for (i=0;i<x.length;i++){document.write("<h2 id=xml_h2>");document.write(x[i].getElementsByTagName("TITLE1")[0].childNodes[0].nodeValue);document.write("</h2>");document.write("<p id=xml_index_p>");document.write(x[i].getElementsByTagName("SUM1")[0].childNodes[0].nodeValue);document.write("</p>");}document.write("</p>");}</script></nowiki></pre>

Muokattu , muokkaaja cor-el

Valittu ratkaisu

Firefox's Error Console (Tools menu) is a rich source of feedback on script errors and security restrictions. After opening the console, it usually is full of CSS warnings. Click the Clear button, then reload your page and check for anything serious. Does that provide any useful feedback?

You also might consider using the XMLHttpRequest object rather than document.implementation.

See https://developer.mozilla.org/en/XmlHttpRequest

Lue tämä vastaus kontekstissaan 👍 0

Kaikki vastaukset (2)

more options

Valittu ratkaisu

Firefox's Error Console (Tools menu) is a rich source of feedback on script errors and security restrictions. After opening the console, it usually is full of CSS warnings. Click the Clear button, then reload your page and check for anything serious. Does that provide any useful feedback?

You also might consider using the XMLHttpRequest object rather than document.implementation.

See https://developer.mozilla.org/en/XmlHttpRequest

more options

Thanks for the help. I've been fiddling with it since posting the question and I realize it was something really wrong with my script. Don't know how it got so screwed up (honestly light years away from where it should be), but just happy to see FF calling my file now.