AJAX Processing Method for XML returned by the server, ajaxxml Processing Method

Source: Internet
Author: User

AJAX Processing Method for XML returned by the server, ajaxxml Processing Method

This article describes how AJAX processes the XML returned by the server. Share it with you for your reference. The specific analysis is as follows:

In AJAX, if the server returns an XML document, you can use the responseXML attribute of the asynchronous object to obtain the XML data of the server. Developers can use DOM-related methods to process them.

Assume that the XML file returned by the server is as follows:

<?xml version="1.0" encoding="gb2312"?><list> <caption>Member List</caption> <member>  <name>isaac</name>  <class>W13</class>  <birth>Jun 24th</birth>  <constell>Cancer</constell>  <mobile>1118159</mobile> </member> <member>  <name>fresheggs</name>  <class>W610</class>  <birth>Nov 5th</birth>  <constell>Scorpio</constell>  <mobile>1038818</mobile> </member> <member>  <name>girlwing</name>  <class>W210</class>  <birth>Sep 16th</birth>  <constell>Virgo</constell>  <mobile>1307994</mobile> </member> <member>  <name>tastestory</name>  <class>W15</class>  <birth>Nov 29th</birth>  <constell>Sagittarius</constell>  <mobile>1095245</mobile> </member> <member>  <name>lovehate</name>  <class>W47</class>  <birth>Sep 5th</birth>  <constell>Virgo</constell>  <mobile>6098017</mobile> </member> <member>  <name>slepox</name>  <class>W19</class>  <birth>Nov 18th</birth>  <constell>Scorpio</constell>  <mobile>0658635</mobile> </member> <member>  <name>smartlau</name>  <class>W19</class>  <birth>Dec 30th</birth>  <constell>Capricorn</constell>  <mobile>0006621</mobile> </member> <member>  <name>tuonene</name>  <class>W210</class>  <birth>Nov 26th</birth>  <constell>Sagittarius</constell>  <mobile>0091704</mobile> </member> <member>  <name>dovecho</name>  <class>W19</class>  <birth>Dec 9th</birth>  <constell>Sagittarius</constell>  <mobile>1892013</mobile> </member> <member>  <name>shanghen</name>  <class>W42</class>  <birth>May 24th</birth>  <constell>Gemini</constell>  <mobile>1544254</mobile> </member> <member>  <name>venessawj</name>  <class>W45</class>  <birth>Apr 1st</birth>  <constell>Aries</constell>  <mobile>1523753</mobile> </member> <member>  <name>lightyear</name>  <class>W311</class>  <birth>Mar 23th</birth>  <constell>Aries</constell>  <mobile>1002908</mobile> </member></list>

The client obtains the XML data from the server and displays it in the table. The Code is as follows:

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html> 

We can see that the code for obtaining the XML file on the client is as follows:

<Input type = "button" value = "Get XML" onclick = "getXML ('9-4. xml');">

That is to say, XML data is directly obtained. In actual development, XML data is returned dynamically through the code on the server side (such as ASP. NET and JSP. In other words, the file address in getXML ('...') should be the suffix of dynamic pages such as. aspx or. jsp.

Implemented using the jQuery framework

If the jQuery framework is used on the client, AJAX is used to obtain XML data on the server.

The Code is as follows:

<Html> 

The method for transferring XML data on the server side remains unchanged.

I hope this article will help you with Ajax programming.

Related Article

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.