1.0 relational data needs to be read in js. we prefer xml files. but how can we read them? The following is a solution ......
We usually have the following requirements::
1.0 relational data needs to be read in js. we prefer xml files. but how can we read them? The following is a solution ......
Step 1:
We can define a method: (the parser is directly returned if only someone calls it)
Function parseXML (file) {try // Internet Explorer --- the parser of IE browser is created as follows: {xmlDoc = new ActiveXObject ("Microsoft. XMLDOM ");} catch (e) {try // Firefox, Mozilla, Opera, etc. firefox and other browsers. {XmlDoc = document. implementation. createDocument ("", "", null);} catch (e) {alert (e. message); return; // if the creation is unsuccessful, return directly without going down. } XmlDoc. async = false; xmlDoc. load (file); return xmlDoc; // return the parser created and send it to the caller. }
Step 2:
Directly call the method in js to obtain the parser: