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

ASP.NET Discussion :

probleme affichage xmldatasource et gridview


Sujet :

ASP.NET

  1. #1
    Membre actif Avatar de amadoulamine1
    Inscrit en
    Avril 2005
    Messages
    260
    Détails du profil
    Informations forums :
    Inscription : Avril 2005
    Messages : 260
    Points : 270
    Points
    270
    Par défaut probleme affichage xmldatasource et gridview
    Salut a tous
    je suis debutant en asp.net et je voudrai afficher un fichier xml dans un gridview
    Mais le probleme il ne m'affiche que le premier attibut "id" de produit seulement
    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="produit.xsl" ?>
    <produits xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="produit.xsd">
      <produit id="OP001">
        <marque>ACER</marque>
        <type id="00001">
          <typeproduit>Ordinateur Portable</typeproduit>
        </type>
        <specifications>
          <specification>
            <type>processeur</type>
            <caracteristique>Intel Core 2 Duo</caracteristique>
          </specification>
          <specification>
            <type>Disque dur</type>
            <caracteristique>SATA 250 Go</caracteristique>
          </specification>
          <specification>
            <type>Memoire</type>
            <caracteristique>DDR 2 2*2Go</caracteristique>
          </specification>
        </specifications>
      </produit>
      <produit id="OP002">
        <marque>HP</marque>
        <type id="00001">
          <typeproduit>Ordinateur Portable</typeproduit>
        </type>
        <specifications>
          <specification>
            <type>processeur</type>
            <caracteristique>Intel Core Duo 1.9 GHTz</caracteristique>
          </specification>
          <specification>
            <type>Disque dur</type>
            <caracteristique>SATA 200 Go</caracteristique>
          </specification>
          <specification>
            <type>Memoire</type>
            <caracteristique>DDR 2 1*2Go</caracteristique>
          </specification>
        </specifications>
      </produit>
    </produits>

    et moi j'aurait voulu qu'il m'affiche l'ensemble des elements .
    Quelqu'un pourrait il m'aider please ...

  2. #2
    Membre actif Avatar de amadoulamine1
    Inscrit en
    Avril 2005
    Messages
    260
    Détails du profil
    Informations forums :
    Inscription : Avril 2005
    Messages : 260
    Points : 270
    Points
    270
    Par défaut
    aparemment j'ai vu qu'une gridview ne pouvait afficher que les attributs presents sur le noeud principal.

    alors j'ai decidé d'y ajouter un xslt

    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <xsl:template match="produits">
        <![CDATA[<?xml version="1.0" encoding="UTF-8"?><produits>]]>
        <xsl:for-each select="produit" >
          <![CDATA[<produit ]]>
          id=<![CDATA["]]><xsl:value-of select="@id"/><![CDATA["]]>
          marque =<![CDATA["]]><xsl:value-of select="marque" /><![CDATA["]]>
          <xsl:for-each select="type" >
            typeproduit=<![CDATA["]]><xsl:value-of select="typeproduit" /><![CDATA["]]>
          </xsl:for-each >
          specifications=<![CDATA["]]>
          <xsl:for-each select="specifications" >
            <xsl:for-each select="specification">
              <xsl:value-of select="type" />
              <xsl:value-of select="caracteristique" />,
            </xsl:for-each >
          </xsl:for-each >
          <![CDATA["]]>
          <![CDATA[/>]]>
        </xsl:for-each >
        <![CDATA[</produits>]]>
      </xsl:template>
    </xsl:stylesheet>
    de telle sorte qu'il s'affiche maintenant sous cette forme
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    <?xml version="1.0" encoding="UTF-8"?>
    <produits>
      <produit id="OP001" marque ="ACER" typeproduit="Ordinateur Portable" specifications="processeurIntel Core 2 Duo, Disque durSATA 250 Go, MemoireDDR 2 2*2Go, "/>
      <produit id="OP002" marque ="HP" typeproduit="Ordinateur Portable" specifications="processeurIntel Core Duo 1.9 GHTz, Disque durSATA 200 Go, MemoireDDR 2 1*2Go, "/>
    </produits>
    mais il ne s'affiche pas
    Par contre si je recopie la structure généree dans une nouvelle feuille xml et que je l'affiche il s'affiche normalement???

    SVP quelqu'un pourrait il m'aider car je n'y comprend plus rien

Discussions similaires

  1. Probleme affichage gridview
    Par guismus650 dans le forum ASP.NET
    Réponses: 4
    Dernier message: 17/07/2008, 17h38
  2. Souci affichage xmlDataSource dans Gridview
    Par nemoz dans le forum ASP.NET
    Réponses: 1
    Dernier message: 15/04/2008, 16h53
  3. [Debutant] Probleme d'affichage de mon Gridview
    Par sebium dans le forum ASP.NET
    Réponses: 1
    Dernier message: 26/05/2007, 14h05
  4. Probleme affichage noir quand Build/Compile
    Par balabi dans le forum MFC
    Réponses: 3
    Dernier message: 01/06/2005, 16h12
  5. Probleme affichage dans tableau selon requête
    Par moulette85 dans le forum Langage SQL
    Réponses: 11
    Dernier message: 01/03/2005, 15h44

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