Friday, 19 April 2013

Parsing XML with JQuery

To parse an XML file with JQuery, you can follow these simple steps.

1. Obtain the xml using JQuery Ajax. There are two possible location where the xml file can be located. You have to make sure of your file path.
2. Parse the Ajax Response (your XML file) and append the data to your html code.

Suppose you have a XML file: (download here)

<student_list>
   <students>
     <student_id>2013001</student_id>
       <name>Clare Marie Ciriaco</name>
    </students>
    <students>
      <student_id>2013002</student_id>
        <name>Jane Doe</name>
   </students>
   <students>
     <student_id>2013003</student_id>
       <name>John Fitzgerald</name>
   </students>
</student_list>

To parse it,


OUTPUT:




0 comments:

Post a Comment