Bonjour bonjour,
Voici mon code pour récupérer et parser un Xml.
Le soucis est que mon parse récupère tout (normal), mais dans le XML donné, vous comprendrez la petite difficulté.
Et voici un extrait du XML récupéré :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 $.ajax({ type: "GET", url: url_api+"/char/AssetList.xml.aspx"+"?keyID="+keyID+"&vCode="+vCode+"&characterID="+characterID, dataType: "xml", error: function(xml, statut, erreur){ alert( "Please CONTACT the DEV : \r\n "+ "An error occurred while processing XML file. \r\n"+ ".../char/AssetList.xml.aspx"); return; }, success: function(xml, statut){ AssetList_assets = new Array(); $(xml).find('row').each( function(){ var tmp_asset = [ $(this).attr('itemID') , $(this).attr('locationID') , $(this).attr('typeID') , $(this).attr('quantity') , $(this).attr('flag') , $(this).attr('singleton') ]; AssetList_assets.push( tmp_asset ); }); }, complete: function(xml, statut){ // $.each( AssetList_assets, function(index, value) { var tmp_html = ''+ '<p>'+ '+value[0]+ ' - '+value[1]+ ' - '+value[2]+ ' - '+value[3]+ ' - '+value[4]+ ' - '+value[5]+ '</p>'+ ''; $("#assets").append( tmp_html ); }); } }); }
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 <rowset name="assets" key="itemID" columns="itemID,locationID,typeID,quantity,flag,singleton"> <row itemID="1016527273080" locationID="60003697" typeID="588" quantity="1" flag="4" singleton="1" rawQuantity="-1"> <rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton"> <row itemID="1016527273082" typeID="3636" quantity="1" flag="27" singleton="1" rawQuantity="-1"/> <row itemID="1016527273083" typeID="3651" quantity="1" flag="28" singleton="1" rawQuantity="-1"/> </rowset> </row> <row itemID="1016519692877" locationID="60006460" typeID="14299" quantity="1" flag="4" singleton="0"/> <row itemID="1014201829151" locationID="60007114" typeID="971" quantity="1" flag="4" singleton="1" rawQuantity="-2"/> <row itemID="1016246141447" locationID="60007114" typeID="3843" quantity="1" flag="4" singleton="0"/> <row itemID="1016250373797" locationID="60007114" typeID="27025" quantity="1" flag="4" singleton="0"/> <row itemID="1016254186075" locationID="60007114" typeID="886" quantity="1" flag="4" singleton="1" rawQuantity="-2"/> <row itemID="1016254208799" locationID="60007114" typeID="1178" quantity="1" flag="4" singleton="1" rawQuantity="-2"/> <row itemID="1016255431153" locationID="60007114" typeID="946" quantity="1" flag="4" singleton="1" rawQuantity="-2"/> <row itemID="1016285060139" locationID="60007114" typeID="2203" quantity="7" flag="4" singleton="0"/> <row itemID="1016285182516" locationID="60007114" typeID="10836" quantity="1" flag="4" singleton="1" rawQuantity="-1"/> <row itemID="1016285549461" locationID="60007114" typeID="439" quantity="3" flag="4" singleton="0"/> <row itemID="1016302851400" locationID="60007114" typeID="221" quantity="514" flag="4" singleton="0"/> <row itemID="1016317654491" locationID="60007114" typeID="6569" quantity="1" flag="4" singleton="1" rawQuantity="-1"/> <row itemID="1016326114569" locationID="60007114" typeID="15588" quantity="6" flag="4" singleton="0"/> <row itemID="1016326221324" locationID="60007114" typeID="15996" quantity="1" flag="4" singleton="0"/> <row itemID="1016327573892" locationID="60007114" typeID="4473" quantity="2" flag="4" singleton="0"/> <row itemID="1016327574335" locationID="60007114" typeID="578" quantity="1" flag="4" singleton="1" rawQuantity="-1"/> <row itemID="1016327950176" locationID="60007114" typeID="9646" quantity="1" flag="4" singleton="0"/> <row itemID="1016328054267" locationID="60007114" typeID="17190" quantity="1" flag="4" singleton="0"/> <row itemID="1016328274441" locationID="60007114" typeID="15607" quantity="13" flag="4" singleton="0"/> <row itemID="1016328345013" locationID="60007114" typeID="15626" quantity="23" flag="4" singleton="0"/> <row itemID="1016343207993" locationID="60007114" typeID="32872" quantity="1" flag="4" singleton="1" rawQuantity="-1"> <rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton"> <row itemID="1016343416167" typeID="32025" quantity="1" flag="94" singleton="1" rawQuantity="-1"/> <row itemID="1016345274210" typeID="31370" quantity="1" flag="93" singleton="1" rawQuantity="-1"/> <row itemID="1016460290299" typeID="222" quantity="683" flag="5" singleton="0"/> </rowset> </row> <row itemID="1016343431227" locationID="60007114" typeID="1137" quantity="1" flag="4" singleton="1" rawQuantity="-1"/> <row itemID="1016344038864" locationID="60007114" typeID="15596" quantity="9" flag="4" singleton="0"/> <row itemID="1016344048764" locationID="60007114" typeID="15597" quantity="6" flag="4" singleton="0"/> <row itemID="1016344285664" locationID="60007114" typeID="225" quantity="400" flag="4" singleton="0"/> <row itemID="1016344375517" locationID="60007114" typeID="218" quantity="356" flag="4" singleton="0"/> </rowset>
Pouvez-vous m'aider ?
Partager