JS reads XML file data and displays data in table format (compatible with IE and Firefox), xmltable

Source: Internet
Author: User

JS reads XML file data and displays data in table format (compatible with IE and Firefox), xmltable

This document describes how to use JavaScript to read XML file data and display data in table format. We will share this with you for your reference. The details are as follows:

First look at the xml file:

<? Xml version = "1.0" standalone = "yes"?> <Student> <stuinfo> <stuName> Zhang qiuli </stuName> <stuSex> female </stuSex> <stuAge> 18 </stuAge> </stuinfo> <stuName> Li wencai </stuName> <stuSex> male </stuSex> <stuAge> 31 </stuAge> </stuinfo> <stuName> Li siwen </stuName> <stuSex> male </stuSex> <stuAge> 22 </stuAge> </stuinfo> <stuName> Ma Ying </stuName> <stuSex> female </stuSex> <stuAge> 25 </stuAge> </stuinfo> <stuName> sun honglei </stuName> <stuSex> male </stuSex> <stuAge> 32 </stuAge> </stuinfo> <stuinfo> <stuName> Ouyang junxiong </stuName> <stuSex> male </stuSex> <stuAge> 28 </stuAge> </stuinfo> <stuName> Jiang Lin </stuName> <stuSex> female </stuSex> <stuAge> 23 </stuAge> </stuinfo> <stuName> small </stuName> <stuSex> female </stuSex> <stuAge> 22 </stuAge> </stuinfo> </student>

Aspx page code:

<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "Get database data to generate XML. aspx. cs "Inherits =" Chapter1. get database data to generate XML "%> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

The above JS operations mainly avoid using childNodes (because in Firefox, sometimes childNodes [0] gets "\ n" instead of the first subnode we want, I can try it myself, but I have encountered this situation) to make it compatible with IE and Firefox. I did not try other browsers.

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.