This article illustrates the way JS reads XML file data and displays the data in table Form. Share to everyone for your reference, specific as follows:
First look at the XML file:
<?xml version= "1.0" standalone= "yes"?> <student> <stuinfo> <stuName> Zhang Qiuli </stuName> < stusex> women </stuSex> <stuAge>18</stuAge> </stuinfo> <stuinfo> <stuName> Force Mogaoyizhang < /stuname> <stuSex> men </stuSex> <stuAge>31</stuAge> </stuinfo> <stuinfo> ;stuname> Lis Wen </stuName> <stuSex> man </stuSex> <stuAge>22</stuAge> </stuinfo> &L t;stuinfo> <stuName> ma </stuName> <stuSex> women </stuSex> <stuAge>25</stuAge> &L t;/stuinfo> <stuinfo> <stuName> Sun Honglei </stuName> <stuSex> men </stuSex> <stuage>32 </stuAge> </stuinfo> <stuinfo> <stuName> Ouyang Junshong </stuName> <stuSex> </stusex>
; <stuAge>28</stuAge> </stuinfo> <stuinfo> <stuName> Jiang Lin </stuName> <stuSex> Female </stuSex> ≪stuage>23</stuage> </stuinfo> <stuinfo> <stuName> small </stuName> <stuSex> female &L
t;/stusex> <stuAge>22</stuAge> </stuinfo> </student>
aspx page code:
<%@ Page language= "C #" autoeventwireup= true "codebehind=" gets the database data generation XML.aspx.cs "inherits=" Chapter1. Get database data Generation XML " %> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
The above JS operation mainly avoids using childnodes (because Firefox sometimes appears childnodes[0] get is "\ n" instead of the first child node we want, this oneself can go to try, anyway I encountered this situation), so that can be compatible with IE, Firefox, Other browsers I didn't try.
More about JavaScript content to view the site topics: "JavaScript operation XML File Tips Summary", "JavaScript Ajax Operating Skills Summary", "JavaScript in the JSON Operation tips Summary", " JavaScript switching effects and techniques summary, "JavaScript Search Algorithm Skills Summary", "JavaScript animation effects and Skills summary", "JavaScript Error and debugging skills Summary", "JavaScript data structure and algorithm skills summary", JavaScript traversal algorithm and techniques summary and JavaScript mathematical Operational Usage Summary
I hope this article will help you with JavaScript programming.