In recent projects, due to access performance issues, internal pages and other static processes have been generated. However, some content in the project needs to be dynamic. according to the previous method, it should be that a dynamic script file will be called using JS. the front-end time was read by Red kids. it seems that some of the code in it is pretty good, and all JS calls XML data, XML can be directly generated using a dynamic script program. In recent projects, due to access performance issues, internal pages and other static processes have been generated. However, some content in the project needs to be dynamic. according to the previous method, it should be that a dynamic script file will be called using JS. the front-end time was read by Red kids. it seems that some of the code in it is pretty good, and all JS calls XML data, XML can be directly generated using a dynamic script program.
The XMl data format is as follows:
Liu Yifei
MingXing/LiuYiFei.htm
7A9D4B
Cai Yilin
MingXing/CaiYiLin.htm
FD0000
Zhang Nala
MingXing/ZhangNaLa.htm
7A9D4B
Zhang Shaohan
MingXiang/ZhangShaoHan.htm
0000FF
Zhang Liangying
MingXing/ZhangLiangYin.htm
7A9D4B
Li Yuchun
MingXing/LiYuChun.htm
7A9D4B
Xu Ruoxi
MingXing/XuLuXuan.htm
FD0000
The front-end JS script code is as follows:
// Obtain the top click rankings of websites
Var cdsales = new ActiveXObject ("Microsoft. XMLDOM "); // create the XmlDom object cdsales. async = true; // asynchronously load cdsales. onreadystatechange = LoadedSales; function LoadedSales () {var txt = ""; if (cdsales. readyState = 4) {if (cdsales. parseError. errorCode! = 0) {txt = "";} else {var bistmcdsales.doc umentElement. selectNodes ("item"); if (bi! = Null & bi. length> 0) {for (var I = 0; I
";}} Else {txt =" ";}}} else {txt =" ";}} sales. innerHTML = txt;} function LoadSalesDoc () {var Url = "/XML/Hot. xml "; cdsales. load (Url );}
The above Hot. Xml can be automatically generated using a program, as long as the output page is in Xml format. It seems that more and more websites have begun to use the p + JS + XML method for architecture, at least the static page can also dynamically read the database. I don't know if this is an Ajax concept.
The above is the details shared by the sample code for JS to read XML data. For more information, see other related articles in the first PHP community!