Jquery | Ajax Read XML file

Source: Internet
Author: User
Tags file url

"1"

Using system;using system.collections.generic;using system.configuration;using system.data;using System.data.sqlclient;using system.io;using system.linq;using system.web;using System.Xml.Serialization;namespace    ajaxxmlapp{//<summary>//Handler1 Summary description///</summary> public class Handler1:ihttphandler {public void ProcessRequest (HttpContext context) {context.            Response.ContentType = "Text/plain"; Context.            Response.Write ("Hello World");            list<userinfo> list = null;            String Str=null; String connectionString = configurationmanager.connectionstrings["Constr"].            ToString (); using (SqlConnection conn = new SqlConnection (connectionString)) {Conn.                Open (); using (SqlCommand cmd = conn.                    CreateCommand ()) {cmd.commandtext = "select * from T_userinfo";          DataTable dt = new DataTable ();          Using (SqlDataAdapter adapter = new SqlDataAdapter (cmd)) {adapter.                    Fill (DT); } list = (from f in dt.                                AsEnumerable () select New UserInfo {                                id = f.field<int> ("id"), UserName = f.field<string> ("UserName"), Name = f.field<string> ("name"), Gender = f.field<int> ("Gender" ), age = f.field<int> ("Age"), addres = F.field<stri Ng> ("Addres"), email = f.field<string> ("email"), Mo                            Bile = f.field<string> ("Mobile"), Remarks = f.field<string> ("Remarks") }).                    ToList (); XmlSerializer XML = new XMLSerializer (typeof (List<userinfo>), "abc");//second parameter: Default namespace for all XML elements (optional) using (FileStream fs = new FileStream (@ "D:/abcd.xml", FileMode.OpenOrCreate)) {XML.                    Serialize (FS, list);                } str= File.readalltext (@ "D:/abcd.xml"); }} context.        Response.Write (str);            } public bool IsReusable {get {return false; }        }    }}

WebForm1.aspx

<%@ page language= "C #" autoeventwireup= "true" codebehind= "WebForm1.aspx.cs" inherits= "Ajaxxmlapp.webform1"%> <! DOCTYPE html>

D:/abcd.xml file

<?xml version= "1.0"? ><arrayofuserinfo xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd= " Http://www.w3.org/2001/XMLSchema "xmlns=" abc "> <UserInfo> <Id>1</Id> <UserName> Salt-free sea </ username> <Name>Fanbin</Name> <Age>27</Age> <Gender>1</Gender> <mobi le>18620996</mobile> <Email>[email protected]</Email> <Addres> </Tianhe District Guangdong province Guangzhou Addres> <Remarks> software engineer </Remarks> </UserInfo> <UserInfo> <Id>2</Id> <u sername>echo</username> <Name>JouJ</Name> <Age>26</Age> <gender>0</gend er> <Mobile>15050587</Mobile> <Email>[email protected]</Email> <Addres> Hunan Provincial Scale Yang City </Addres> <Remarks> audit </Remarks> </UserInfo> <UserInfo> <Id>3</Id> & Lt Username> Little Monk </UserName> <name> </Name> <Age>26</Age> <Gender>0</Gender> <mobile>1890117</mobil e> <Email>[email protected]</Email> <Addres> Jiangsu Nanjing </Addres> <Remarks> Audit < /remarks> </UserInfo> <UserInfo> <Id>4</Id> <UserName> core Baby </UserName> &lt ; name> Rolliri </Name> <Age>26</Age> <Gender>0</Gender> <mobile>186201008</mob Ile> <Email>[email protected]</Email> <Addres> Hunan province Changsha </Addres> <Remarks> accounting &L    t;/remarks> </UserInfo> <UserInfo> <Id>5</Id> <UserName>Spring</UserName> <Name> Zhouquanquan </Name> <Age>26</Age> <Gender>0</Gender> <Mobile>1367535< /mobile> <Email>[email protected]</Email> <Addres> Hunan Governor Chaanine Township </Addres> <remarks&gt  ; Business English </Remarks></UserInfo> <UserInfo> <Id>6</Id> <UserName> Little Women </UserName> <Name> Deng O&lt ;/name> <Age>26</Age> <Gender>0</Gender> <Mobile>1868860</Mobile> <e mail>[email protected]</email> <Addres> Hunan Yongzhou </Addres> <Remarks> Hello! </Remarks> </UserInfo> <UserInfo> <Id>10</Id> <UserName> @userName </username > <Name> @name </Name> <Age>25</Age> <Gender>0</Gender> <Mobile> @mo bile</mobile> <Email> @email </Email> <Addres> @addres </Addres> <Remarks> @remark    s</remarks> </UserInfo> <UserInfo> <Id>22</Id> <UserName> ice cream </UserName> <Name> Snow Fly </Name> <Age>25</Age> <Gender>0</Gender> <mobile>18620082008 </Mobile> <email>[email p rotected]</email> <Addres> Guangzhou tianhe </Addres> <Remarks> No Comments </Remarks> </UserInfo> </ArrayOfUserInfo>







Jquery | Ajax Read XML file

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.