Parse XML via jquery on listview jquerymobile
hello i want load xml data into listview onmy jquery mobile using ajax but don't work
here is html
- <div data-role="page" id="VHC">
- <header data-role="header" id="head_home">
- <div class="top_head_home"></div><br />
- <div class="fot_head_home"></div>
- </header>
- <div data-role="navbar">
- <ul>
- <li><a href="#home" data-icon="back">Retour</a></li>
- <li><a href="#home" data-icon="home">Accueil</a></li>
- <li><a href="#rch" data-icon="search">Recherche</a></li>
- </ul>
- </div>
- <section data-role="content" id="cont_home">
- <a href="#"><div class="list"></div></a>
- </section>
- <footer data-role="footer" id="foot_Auth">
- <div class="top_footer_auth"></div>
- <div class="fot_footer_auth">TEST COPYRIGHT<sup>©</sup>2015</div>
- </footer>
- </div>
here is js script
- $(document).ready(function()
- {
- $.ajax({
- type: "GET",
- url: "vehicules.xml",
- dataType: "xml",
- success: parseXml
- });
- });
-
- function parseXml(xml)
- {
- $("#list").html("<ul id='content' data-role='listview' data-inset='true'></ul>");
- $(xml).find("vehicule").each(function()
- {
- $("#content").append("<li><a href='"+$(this).find("codeid").text()+"'><h2>"+$(this).find("driver").text()+"</h2><p>"+$(this).find("type").text()+"</p></a></li>");
- });
- }
here is the xml code
- <?xml version="1.0" encoding="utf-8"?>
- <vehicules>
- <vehicule>
- <codeid >87521</codeid>
- <driver>Salim</driver>
- <type>Subaru Impreza WRX STI 2015</type>
- <speed>60km/h</speed>
- </vehicule>
- <vehicule>
- <codeid >892317</codeid>
- <driver>Bilel</driver>
- <type>BWM X6</type>
- <speed>160km/h</speed>
- </vehicule>
- <vehicule>
- <codeid >25741</codeid>
- <driver>Noor</driver>
- <type>Citroen C3</type>
- <speed>60km/h</speed>
- </vehicule>
- </BookList>
-