GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing en.wikibooks.org — JavaScript/Handling XML - Wikibooks, open books for an open world
Simple function to open an XML fileThis function first tries for Microsoft Internet Explorer, then for Firefox and others: function loadXMLDoc(xmlfilename) { var event = new Error(); // Internet Explorer try { var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); } catch(event) { // Firefox, Mozilla, Opera, others try { xmlDoc = document.implementation.createDocument("","",null); } catch(event) { throw(event.message); } } try { xmlDoc.async = false; xmlDoc.load(xmlfilename); return(xmlDoc); } catch(event) { throw(event.message); } return(null); } Usagevar objXML = loadXMLDoc("filename.xml"); var oNodes = objXML.getElementsByTagName("AnyTagYouWish"); Now you can do any DOM operations on oNodes. XML modifications can't be saved in JavaScript, as this is clientside… |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |