IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

jQuery Discussion :

Xml Parse récupère tout le XML


Sujet :

jQuery

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre régulier
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juillet 2014
    Messages : 7
    Par défaut Xml Parse récupère tout le XML
    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é.

    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 );
    		});
    	}
    });
    }
    Et voici un extrait du XML récupéré :
    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 ?

  2. #2
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 658
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 75
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 658
    Billets dans le blog
    1
    Par défaut
    T'aider à quoi ?
    elle est ou la difficulté ? dans les undefined ? (perso je n'ai pas compris ...)

    http://jsfiddle.net/dj05z8o9/2/
    Ma page Developpez - Mon Blog Developpez
    Président du CCMPTP (Comité Contre le Mot "Problème" dans les Titres de Posts)
    Deux règles du succès: 1) Ne communiquez jamais à quelqu'un tout votre savoir...
    Votre post est résolu ? Alors n'oubliez pas le Tag

    Venez sur le Chat de Développez !

  3. #3
    Membre régulier
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juillet 2014
    Messages : 7
    Par défaut
    Oui en fait les lignes où il y a des Undefined, c'est parce que ce sont des fils.

    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <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"/>

    Donc je me demandais comment bien parser le premier niveau et les seconds niveaux.

    Est-ce un peu plus clair ? désolé pour le malentendu

  4. #4
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 658
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 75
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 658
    Billets dans le blog
    1
    Par défaut
    ben tu as des rowset ...
    http://jsfiddle.net/dj05z8o9/3/

    il faudrait y ajouter la recursivité ... si tu tiens à récupérer la hierarchie
    Ma page Developpez - Mon Blog Developpez
    Président du CCMPTP (Comité Contre le Mot "Problème" dans les Titres de Posts)
    Deux règles du succès: 1) Ne communiquez jamais à quelqu'un tout votre savoir...
    Votre post est résolu ? Alors n'oubliez pas le Tag

    Venez sur le Chat de Développez !

  5. #5
    Membre régulier
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juillet 2014
    Messages : 7
    Par défaut
    Bonjour,

    Merci de ta réponse, ça me met sur la piste, mais j'ai vraiment du mal :/
    Evidemment je voudrais tout récupérer dans une variable tableau multidimensionnel.

    je redonne le XML que je dois traiter (plus précis)

    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
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    <api version="2">
    	<currentTime>2014-12-03 11:15:40</currentTime>
    	<result>
    	<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="1016386131198" locationID="60007114" typeID="5087" quantity="4" flag="4" singleton="0"/>
    		<row itemID="1016392015209" locationID="60007114" typeID="657" quantity="1" flag="4" singleton="1" rawQuantity="-1">
    			<rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
    				<row itemID="1016392659255" typeID="31119" quantity="1" flag="92" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016392820686" typeID="1319" quantity="1" flag="5" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016617198877" typeID="5561" quantity="1" flag="12" singleton="1" rawQuantity="-1"/>
    			</rowset>
    		</row>
    		<row itemID="1016392506213" locationID="60007114" typeID="35" quantity="30533" flag="4" singleton="0"/>
    		<row itemID="1016392506217" locationID="60007114" typeID="38" quantity="1150" flag="4" singleton="0"/>
    		<row itemID="1016392509058" locationID="60007114" typeID="39" quantity="1" flag="4" singleton="0"/>
    		<row itemID="1016395398228" locationID="60007114" typeID="17480" quantity="1" flag="4" singleton="1" rawQuantity="-1">
    			<rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
    				<row itemID="1015447332020" typeID="2454" quantity="1" flag="87" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016256272587" typeID="32375" quantity="1" flag="5" singleton="0"/>
    				<row itemID="1016343963834" typeID="2454" quantity="1" flag="87" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016571595790" typeID="22576" quantity="1" flag="5" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016571597418" typeID="22576" quantity="1" flag="5" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016622262410" typeID="22542" quantity="1" flag="12" singleton="1" rawQuantity="-1"/>
    			</rowset>
    		</row>
    		<row itemID="1016401844459" locationID="60007114" typeID="12188" quantity="1" flag="4" singleton="0"/>
    		<row itemID="1016411389760" locationID="60007114" typeID="18053" quantity="1" flag="4" singleton="1" rawQuantity="-1"/>
    		<row itemID="1016411391068" locationID="60007114" typeID="18063" quantity="1" flag="4" singleton="1" rawQuantity="-1"/
    		<row itemID="1016525557711" locationID="60007114" typeID="4025" quantity="2" flag="4" singleton="0"/>
    		<row itemID="1016526327644" locationID="60007114" typeID="588" quantity="5" flag="4" singleton="0"/>
    		<row itemID="1016535207897" locationID="60007114" typeID="2464" quantity="5" flag="4" singleton="0"/>
    		<row itemID="1016535207922" locationID="60007114" typeID="32787" quantity="1" flag="4" singleton="0"/>
    		<row itemID="1016541940280" locationID="60007114" typeID="626" quantity="1" flag="4" singleton="1" rawQuantity="-1">
    			<rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
    				<row itemID="1016344285667" typeID="2173" quantity="1" flag="87" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016344854615" typeID="24348" quantity="1" flag="29" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016490970711" typeID="2486" quantity="1" flag="87" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016491345871" typeID="23527" quantity="1" flag="30" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016628922365" typeID="2454" quantity="1" flag="87" singleton="1" rawQuantity="-1"/>
    			</rowset>
    		</row>
    		<row itemID="1016542005875" locationID="60007114" typeID="523" quantity="1" flag="4" singleton="0"/>
    		<row itemID="1016542005877" locationID="60007114" typeID="4535" quantity="3" flag="4" singleton="0"/>
    		<row itemID="1016542005879" locationID="60007114" typeID="4529" quantity="1" flag="4" singleton="0"/>
    		<row itemID="1016617167286" locationID="60007114" typeID="11129" quantity="1" flag="4" singleton="0"/>
    		<row itemID="1016618072680" locationID="60007114" typeID="607" quantity="1" flag="4" singleton="1" rawQuantity="-1">
    			<rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
    				<row itemID="1016516379164" typeID="5971" quantity="1" flag="19" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016618074343" typeID="11370" quantity="1" flag="27" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016618086067" typeID="31201" quantity="1" flag="93" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016618086952" typeID="31238" quantity="1" flag="92" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016618092691" typeID="16301" quantity="1" flag="11" singleton="1" rawQuantity="-1"/>
    			</rowset>
    		</row>
    		<row itemID="1016618105423" locationID="60007114" typeID="22542" quantity="1" flag="4" singleton="0"/>
    		<row itemID="1016618399474" locationID="60007114" typeID="25600" quantity="31" flag="4" singleton="0"/>
    		<row itemID="1016542868635" locationID="60008494" typeID="6675" quantity="1" flag="4" singleton="0"/>
    		<row itemID="1016590098749" locationID="60008494" typeID="3636" quantity="1" flag="4" singleton="1" rawQuantity="-1"/>
    		<row itemID="1016590098750" locationID="60008494" typeID="3651" quantity="1" flag="4" singleton="1" rawQuantity="-1"/>
    		<row itemID="1016618067258" locationID="60008494" typeID="588" quantity="1" flag="4" singleton="1" rawQuantity="-1">
    			<rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
    				<row itemID="1016618067260" typeID="3636" quantity="1" flag="27" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016618067261" typeID="3651" quantity="1" flag="28" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016618067264" typeID="34" quantity="1" flag="5" singleton="0"/>
    			</rowset>
    		</row>
    		<row itemID="1016368255899" locationID="60014635" typeID="32880" quantity="1" flag="4" singleton="1" rawQuantity="-1">
    			<rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
    				<row itemID="1016543625314" typeID="17938" quantity="1" flag="29" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016590079404" typeID="5971" quantity="1" flag="19" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016405238540" typeID="25266" quantity="1" flag="27" singleton="1" rawQuantity="-1"/>
    			</rowset>
    		</row>
    		<row itemID="1016510184504" locationID="60014635" typeID="2454" quantity="5" flag="4" singleton="0"/>
    		<row itemID="1016527273086" locationID="60014635" typeID="34" quantity="1" flag="4" singleton="0"/>
    		<row itemID="1016527280676" locationID="60014635" typeID="626" quantity="1" flag="4" singleton="1" rawQuantity="-1">
    			<rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
    				<row itemID="1016527962440" typeID="5975" quantity="1" flag="19" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016527995382" typeID="31055" quantity="1" flag="93" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016528201901" typeID="2183" quantity="3" flag="87" singleton="0"/>
    				<row itemID="1016528210308" typeID="2464" quantity="4" flag="87" singleton="0"/>
    				<row itemID="1016528284705" typeID="28286" quantity="1" flag="87" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016528578487" typeID="2464" quantity="1" flag="87" singleton="1" rawQuantity="-1"/>
    				<row itemID="1016528619566" typeID="23527" quantity="1" flag="30" singleton="1" rawQuantity="-1"/>
    			</rowset>
    		</row>
    		<row itemID="1016510190911" locationID="60014635" typeID="28286" quantity="1" flag="4" singleton="0"/>
    		<row itemID="1016525636050" locationID="60008494" typeID="8091" quantity="1" flag="4" singleton="0"/>
    	</rowset>
    	</result>
    	<cachedUntil>2014-12-03 17:15:38</cachedUntil>
    </api>

  6. #6
    Membre régulier
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juillet 2014
    Messages : 7
    Par défaut
    Bon au final, j'ai trouvé une solution... qui marche pour moi

    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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
     
    AssetList_assets = [];
    $(AssetList_xml).find('row').each( function()
    {
    	AssetList_assets.push( [
    		$(this).attr('locationID'),
    		$(this).attr('typeID'),
    		$(this).attr('itemID'),
    		$(this).attr('quantity'),
    		$(this).attr('flag'),
    		$(this).attr('singleton')
    	] );
    });
     
    tmp_parent_id = 0;
    tmp_html = "";
    tmp_html += ''+
    	'<table id="Assets_Table" cellspacing="0">' +
    	'	<caption>' +
    	'		<a href="#" onclick="jQuery(\'#Assets_Table\').treetable(\'expandAll\'); return false;">Expand all</a> | ' +
    	'		<a href="#" onclick="jQuery(\'#Assets_Table\').treetable(\'collapseAll\'); return false;">Collapse all</a>' +
    	'	</caption>' +
    	'	<thead>'+
    	'		<tr>'+
    	'			<th class="ui-corner-tl">locationID</th>'+
    	'			<th>typeID</th>'+
    	'			<th>itemID</th>'+
    	'			<th>quantity</th>'+
    	'			<th>flag</th>'+
    	'			<th class="ui-corner-tr">singleton</th>'+
    	'		</tr>'+
    	'	</thead>'+
    	'	<tbody>'+
    '';
    $.each( AssetList_assets, function(index, value) 
    {		
    	tmp_html_current_id = ' data-tt-id="'+value[2]+'"';
    	tmp_html_parent_id = "";
    	tmp_child_class = "";
    	tmp_location = "";
     
    	if( !value[0] ) {
    		tmp_location = "";
    		tmp_child_class = ' class="branch_child"';
    		tmp_html_parent_id = ' data-tt-parent-id="'+tmp_parent_id+'"';
    	} else {
    		tmp_location = value[0];
    	}
     
    	tmp_html += ''+
    	'		<tr'+tmp_html_current_id+tmp_html_parent_id+tmp_child_class+'>'+
    	'			<td>'+tmp_location+'</td>'+
    	'			<td>'+value[1]+'</td>'+
    	'			<td>'+value[2]+'</td>'+
    	'			<td>'+value[3]+'</td>'+
    	'			<td>'+value[4]+'</td>'+
    	'			<td>'+value[5]+'</td>'+
    	'		</tr>'+
    	'';
    	if( value[0] ) {
    		tmp_parent_id = value[2];
    	}
    });
    tmp_html += ''+
    	'	</tbody>'+
    	'	<tfoot>'+
    	'		<tr>'+
    	'			<th class="ui-corner-bl">TOTO sum</th>'+
    	'			<th>TOTO sum</th>'+
    	'			<th>TOTO sum</th>'+
    	'			<th>TOTO sum</th>'+
    	'			<th>TOTO sum</th>'+
    	'			<th class="ui-corner-br">TOTO sum</th>'+
    	'		</tr>'+
    	'	</tfoot>'+
    	'</table>' +
    '';
    $("#assets").append( tmp_html );
     
    $("#Assets_Table").treetable({
    	expandable: true
    });

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [JDOM] [Compil] parse d'un fichier xml
    Par ammah dans le forum Format d'échange (XML, JSON...)
    Réponses: 2
    Dernier message: 13/06/2006, 17h34
  2. Réponses: 3
    Dernier message: 16/02/2006, 18h38
  3. [DOM] Erreur lors du parsing d'un fichier XML par l'API DOM
    Par patricetoan dans le forum Format d'échange (XML, JSON...)
    Réponses: 5
    Dernier message: 26/09/2005, 12h43
  4. XML Parsing Error: not well-formed
    Par localhost dans le forum Valider
    Réponses: 5
    Dernier message: 16/06/2005, 14h20
  5. Réponses: 14
    Dernier message: 25/10/2004, 21h33

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo