[JavaScript]函数loadXMLString
1function loadXMLString(txt)
2{
3 try
4 { //Internet Explorer
5 xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
6 xmlDoc.async= false;
7 xmlDoc.loadXML(txt);
8 return(xmlDoc);
9 }
10 catch(e)
11 {
12 try
13 {//Firefox,Mozilla,Opera,etc
14 parser = new DomParser();
15 xmlDoc = parser.parseFormString(txt,"text/xml");
16 return(xmlDoc);
17 }
18 catch(e)
19 {
20 alert(e.message())
21 return(null);
22 }
23 }
24}
2{
3 try
4 { //Internet Explorer
5 xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
6 xmlDoc.async= false;
7 xmlDoc.loadXML(txt);
8 return(xmlDoc);
9 }
10 catch(e)
11 {
12 try
13 {//Firefox,Mozilla,Opera,etc
14 parser = new DomParser();
15 xmlDoc = parser.parseFormString(txt,"text/xml");
16 return(xmlDoc);
17 }
18 catch(e)
19 {
20 alert(e.message())
21 return(null);
22 }
23 }
24}