JS read the XML file data and display the data in table Form (compatible with IE and Firefox) _javascript tips

Source: Internet
Author: User
Tags dname

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&gt
  ;  <stuAge>28</stuAge> </stuinfo> <stuinfo> <stuName> Jiang Lin </stuName> <stuSex> Female </stuSex> &Lt;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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.