Rechercher dans l’assistance

Évitez les escroqueries à l’assistance. Nous ne vous demanderons jamais d’appeler ou d’envoyer un SMS à un numéro de téléphone ou de partager des informations personnelles. Veuillez signaler toute activité suspecte en utilisant l’option « Signaler un abus ».

Learn More

Trouble getting XML to display

  • 2 réponses
  • 2 ont ce problème
  • 111 vues
  • Dernière réponse par 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>

Modifié le par cor-el

Solution choisie

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

Lire cette réponse dans son contexte 👍 0

Toutes les réponses (2)

more options

Solution choisie

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.