requete selective dans fichier xml -- selective query in xml file
Bonjour,
je débute actuellement dans jQuery.
J'ai réussi a parser mon fichier xml, mais j'aurais voulu pouvoir afficher les données en fonction d'un critère de filtre, une sorte de requête sql :
-> select * from 'table' where pays = 'paramètre'.
est-ce possible? si oui, comment je doit m'y prendre?
voici un extrait du fichier xml:
1. <markers>
<marker name="a" lat="55.23076" lng="66.06605" logo="images/a.png" url="http://www.a.ch" details="">
<inst>"a"</inst>
<pays>Switzerland</pays>
<url>http://www.a.ch</url>
<code>a</code>
<lat>55.23076</lat>
<lng>66.06605</lng>
</marker>
</markers>
voici le code de parsing:
1. function test(recup)
//Fonction qui affiche les instituts en fonction du pays séléctionné
{
$.ajax( {
type: "GET",
url: "instituts.xml",
dataType: "xml",
success: function(xml)
{
$(xml).find('marker').each(
function()
{
var code = $(this).find('code').text();
var gps = $(this).find('gps').text();
var lat = $(this).find('lat').text();
var lng = $(this).find('lng').text();
var inst = $(this).find('inst').text();
var instStr = "<a onClick=\"JavaScript:changerPointeur('"+lat+","+lng+"')\" title="+inst+">"+code+'<br>';
$(instStr).appendTo('#instituts');
});
}
});
}
Mon but est de sélectionner le contenu de <inst> en fonction du pays...
Merci d'avance...
Math11
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Hello
I begin now in jQuery.
I managed to parse my xml file, but I wanted to display data based on a filter criteria, so a sql query:
-> select * from 'table' where country = 'parameter'.
Is this possible? if so, how should I go about it?
Here is an excerpt from the xml file:
<markers>
<marker name="a" lat="55.23076" lng="66.06605" logo="images/a.png" url="http://www.a.ch" details="">
<inst>"a"</inst>
<pays>Switzerland</pays>
<url>http://www.a.ch</url>
<code>a</code>
<lat>55.2307</lat>
<lng>66.06605</lng>
</marker>
</markers>
here is the code parsing:
function test (recup)
/ / Function that displays the institutions selected by country
(
$. Ajax ((
type: "GET",
url: "instituts.xml"
dataType: "xml",
success: function (xml)
(
$ (Xml).find('marker').each (
function()
(
var code = $ (this).find ("code").text();
var lat = $( this). find('lat').text();
var lng = $ (this). find('lng ").text();
var inst = $ (this).find('inst').text();
instStr var = "<a onClick=\"JavaScript:changerPointeur('"+lat+","+lng+"')\" title="+inst+">" + code + '<br>';
$ (instStr). appendTo ('#instituts');
));
)
));
)
My goal is to select the contents of <inst> by country ...
Thank you in advance ...
Math11