Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Desperate seeking answer to simple problem

Desperate seeking answer to simple problem

Scheduled Pinned Locked Moved XML / XSL
xmlhelpquestiondatabase
8 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Axiom70m
    wrote on last edited by
    #1

    Hello, I got a simple question and i geuss the answer will be simple to. I've just spend 8 hours looking at this but can't seem to solve it. I Got a gridview that shows data from an exsisting XML file. The user can select items the gridview with checkboxes. When the user hits the next button the xml file should be updating the showimage attribute with "0" or "1" from the checkbox value of the gridview. the XML is wellformed and has a schema. basically it looks like this root itemcode filename showimage= etc etc /root root itemcode filename showimage= etc etc /root root itemcode filename showimage= etc etc /root I have come as far as :

    For Each row As GridViewRow In GrdImagesSel.Rows

            Dim cbSi As CheckBox = row.FindControl("chkShowImage")
            Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value)
            Dim SiNodelist As XmlNodeList
            Dim SiNode As XmlNode
            SiNodelist = xmldoc.SelectNodes("docroot/root")
            For Each SiNode In SiNodelist
                Dim ShowImg = SiNode.ChildNodes.Item(1).InnerText
                If ShowImg = productID Then Parentnode.Attributes("ShowImage").Value = cbSi.Text
    
            Next
        Next
    

    that doesn't work. Can you help me out here? Regards, Bram

    N 1 Reply Last reply
    0
    • A Axiom70m

      Hello, I got a simple question and i geuss the answer will be simple to. I've just spend 8 hours looking at this but can't seem to solve it. I Got a gridview that shows data from an exsisting XML file. The user can select items the gridview with checkboxes. When the user hits the next button the xml file should be updating the showimage attribute with "0" or "1" from the checkbox value of the gridview. the XML is wellformed and has a schema. basically it looks like this root itemcode filename showimage= etc etc /root root itemcode filename showimage= etc etc /root root itemcode filename showimage= etc etc /root I have come as far as :

      For Each row As GridViewRow In GrdImagesSel.Rows

              Dim cbSi As CheckBox = row.FindControl("chkShowImage")
              Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value)
              Dim SiNodelist As XmlNodeList
              Dim SiNode As XmlNode
              SiNodelist = xmldoc.SelectNodes("docroot/root")
              For Each SiNode In SiNodelist
                  Dim ShowImg = SiNode.ChildNodes.Item(1).InnerText
                  If ShowImg = productID Then Parentnode.Attributes("ShowImage").Value = cbSi.Text
      
              Next
          Next
      

      that doesn't work. Can you help me out here? Regards, Bram

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      One, without formatting the xml properly it's difficult to see your structure.

      Axiom70m wrote:

      that doesn't work.

      Two, you have to give a little more information than this. What doesn't work? Are you getting exceptions? Is it just not functioning?


      I know the language. I've read a book. - _Madmatt

      A 1 Reply Last reply
      0
      • N Not Active

        One, without formatting the xml properly it's difficult to see your structure.

        Axiom70m wrote:

        that doesn't work.

        Two, you have to give a little more information than this. What doesn't work? Are you getting exceptions? Is it just not functioning?


        I know the language. I've read a book. - _Madmatt

        A Offline
        A Offline
        Axiom70m
        wrote on last edited by
        #3

        Hi, Thanks for you message. Here's the XML file:

        <AfasGetConnector>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="AfasGetConnector">
        xs:complexType
        <xs:choice maxOccurs="unbounded">
        <xs:element name="MNINT_Summary">
        xs:complexType
        xs:sequence
        <xs:element name="Itemtype" type="xs:string" minOccurs="0" />
        etc etc
        <xs:element name="Afbeelding_in_Summary" type="xs:boolean" />
        </xs:sequence>
        </xs:complexType>
        </xs:element>
        </xs:choice>
        </xs:complexType>
        </xs:element>
        </xs:schema>
        <MNINT_Summary>
        <Itemtype>2</Itemtype>
        <Itemcode>0401023100</Itemcode>
        <Omschrijving>Tales Legends - The Erzberg</Omschrijving>
        <Gewichtseenheid_code>3</Gewichtseenheid_code>
        <Bruto_gewicht>16</Bruto_gewicht>
        <Bestandsnaam ShowImage="">ERZBERGAVRV.JPG</Bestandsnaam>
        <Artikelcode>3988</Artikelcode>
        <Nominale_waarde>€ 10</Nominale_waarde>
        <Jaartal>2010</Jaartal>
        <Metaal>Silver</Metaal>
        <Kwaliteit>Proof</Kwaliteit>
        <Fijnheid>.925</Fijnheid>
        <Diameter>32</Diameter>
        <Mintage>40000</Mintage>
        <Prijs_5>24</Prijs_5>
        <Prijs_25>22</Prijs_25>
        <Prijs_50>20.75</Prijs_50>
        <Prijs_100>19.9</Prijs_100>
        <Sold_Out>false</Sold_Out>
        <Land>Austria</Land>
        <Logo_mint>AUT</Logo_mint>
        <Gewijzigd_op>2010-03-10</Gewijzigd_op>
        <Aangemaakt_op>2009-10-06</Aangemaakt_op>
        <Uitgifte_datum>2010-04-14</Uitgifte_datum>
        <Opnemen_in_Summary>false</Opnemen_in_Summary>
        <Afbeelding_in_Summary>true</Afbeelding_in_Summary>
        </MNINT_Summary>
        <MNINT_Summary>
        <Itemtype>2</Itemtype>
        <Itemcode>0401023400</Itemcode>
        <Omschrijving>Tales Legends - The Erzberg</Omschrijving>
        <Gewichtseenheid_code>3</Gewichtseenheid_code>
        <Bruto_gewicht>16</Bruto_gewicht>
        <Bestandsnaam ShowImage="">ERZBERGAVRV.JPG</Bestandsnaam>
        <A

        N 1 Reply Last reply
        0
        • A Axiom70m

          Hi, Thanks for you message. Here's the XML file:

          <AfasGetConnector>
          <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
          <xs:element name="AfasGetConnector">
          xs:complexType
          <xs:choice maxOccurs="unbounded">
          <xs:element name="MNINT_Summary">
          xs:complexType
          xs:sequence
          <xs:element name="Itemtype" type="xs:string" minOccurs="0" />
          etc etc
          <xs:element name="Afbeelding_in_Summary" type="xs:boolean" />
          </xs:sequence>
          </xs:complexType>
          </xs:element>
          </xs:choice>
          </xs:complexType>
          </xs:element>
          </xs:schema>
          <MNINT_Summary>
          <Itemtype>2</Itemtype>
          <Itemcode>0401023100</Itemcode>
          <Omschrijving>Tales Legends - The Erzberg</Omschrijving>
          <Gewichtseenheid_code>3</Gewichtseenheid_code>
          <Bruto_gewicht>16</Bruto_gewicht>
          <Bestandsnaam ShowImage="">ERZBERGAVRV.JPG</Bestandsnaam>
          <Artikelcode>3988</Artikelcode>
          <Nominale_waarde>€ 10</Nominale_waarde>
          <Jaartal>2010</Jaartal>
          <Metaal>Silver</Metaal>
          <Kwaliteit>Proof</Kwaliteit>
          <Fijnheid>.925</Fijnheid>
          <Diameter>32</Diameter>
          <Mintage>40000</Mintage>
          <Prijs_5>24</Prijs_5>
          <Prijs_25>22</Prijs_25>
          <Prijs_50>20.75</Prijs_50>
          <Prijs_100>19.9</Prijs_100>
          <Sold_Out>false</Sold_Out>
          <Land>Austria</Land>
          <Logo_mint>AUT</Logo_mint>
          <Gewijzigd_op>2010-03-10</Gewijzigd_op>
          <Aangemaakt_op>2009-10-06</Aangemaakt_op>
          <Uitgifte_datum>2010-04-14</Uitgifte_datum>
          <Opnemen_in_Summary>false</Opnemen_in_Summary>
          <Afbeelding_in_Summary>true</Afbeelding_in_Summary>
          </MNINT_Summary>
          <MNINT_Summary>
          <Itemtype>2</Itemtype>
          <Itemcode>0401023400</Itemcode>
          <Omschrijving>Tales Legends - The Erzberg</Omschrijving>
          <Gewichtseenheid_code>3</Gewichtseenheid_code>
          <Bruto_gewicht>16</Bruto_gewicht>
          <Bestandsnaam ShowImage="">ERZBERGAVRV.JPG</Bestandsnaam>
          <A

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Based on this schema your XPath expression would be "AfasGetConnector/MNINT_Summary[Itemcode=productID]"

          XmlNode node = doc.SelectSingleNode("AfasGetConnector/MNINT_Summary[Itemcode=productID]");


          I know the language. I've read a book. - _Madmatt

          A 1 Reply Last reply
          0
          • N Not Active

            Based on this schema your XPath expression would be "AfasGetConnector/MNINT_Summary[Itemcode=productID]"

            XmlNode node = doc.SelectSingleNode("AfasGetConnector/MNINT_Summary[Itemcode=productID]");


            I know the language. I've read a book. - _Madmatt

            A Offline
            A Offline
            Axiom70m
            wrote on last edited by
            #5

            Thanks for your input, I realy appriciate it. I'm still not sure how to make this work... How do I set the checkbox value in the ShowImage attribute XML? Now only the last ShowImage attribute in the X For Each row As GridViewRow In GrdImagesSel.Rows Dim cbSi As CheckBox = row.FindControl("chkShowImage") Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value) Dim SiNode As XmlNode SiNode = xmldoc.SelectSingleNode("AfasGetConnector/MNINT_Summary[Itemcode=productID]") For Each SiNode In xmldoc Parentnode.Attributes("ShowImage").Value = ("1") Next Next Thank for reading

            modified on Wednesday, April 28, 2010 4:13 AM

            N 1 Reply Last reply
            0
            • A Axiom70m

              Thanks for your input, I realy appriciate it. I'm still not sure how to make this work... How do I set the checkbox value in the ShowImage attribute XML? Now only the last ShowImage attribute in the X For Each row As GridViewRow In GrdImagesSel.Rows Dim cbSi As CheckBox = row.FindControl("chkShowImage") Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value) Dim SiNode As XmlNode SiNode = xmldoc.SelectSingleNode("AfasGetConnector/MNINT_Summary[Itemcode=productID]") For Each SiNode In xmldoc Parentnode.Attributes("ShowImage").Value = ("1") Next Next Thank for reading

              modified on Wednesday, April 28, 2010 4:13 AM

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              Please stop what you are doing and read the documentation for XmlDocument and related objects. You can not use for/each on SiNode. SelectSingleNode Care to guess how many nodes this will return?


              I know the language. I've read a book. - _Madmatt

              A 1 Reply Last reply
              0
              • N Not Active

                Please stop what you are doing and read the documentation for XmlDocument and related objects. You can not use for/each on SiNode. SelectSingleNode Care to guess how many nodes this will return?


                I know the language. I've read a book. - _Madmatt

                A Offline
                A Offline
                Axiom70m
                wrote on last edited by
                #7

                That was not the smartest thing to do. I am totally lost here and getting a bit obsessed with this. I can't figure out how I should do this, i thought it would be easier this way. If you can give me any clue it would be very much appreciated. Thanks for your replies and time. Regards, Bram

                A 1 Reply Last reply
                0
                • A Axiom70m

                  That was not the smartest thing to do. I am totally lost here and getting a bit obsessed with this. I can't figure out how I should do this, i thought it would be easier this way. If you can give me any clue it would be very much appreciated. Thanks for your replies and time. Regards, Bram

                  A Offline
                  A Offline
                  Axiom70m
                  wrote on last edited by
                  #8

                  Thanks for the help, i solved the problem

                  For Each row As GridViewRow In GrdImagesSel.Rows
                  Dim cbSi As CheckBox = row.FindControl("chkShowImage")
                  'Koppel Itemcode van de row aan productID en

                          If cbSi IsNot Nothing AndAlso cbSi.Checked Then
                              Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value)
                              Dim root As XmlNode = xmldoc.DocumentElement
                              Dim nodeList As XmlNodeList = root.SelectNodes("MNINT\_Summary/Itemcode")
                              For Each productNode As XmlNode In nodeList
                                  If productNode.FirstChild.InnerText = productID Then
                                      Dim ShowImage As XmlElement = xmldoc.CreateElement("ShowImage")
                                      productNode.AppendChild(ShowImage)
                                      ShowImage.InnerText = "1"
                                  End If
                              Next
                          Else
                              Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value)
                              Dim root As XmlNode = xmldoc.DocumentElement
                              Dim nodeList As XmlNodeList = root.SelectNodes("MNINT\_Summary/Itemcode")
                              For Each productNode As XmlNode In nodeList
                                  If productNode.FirstChild.InnerText = productID Then
                                      Dim ShowImage As XmlElement = xmldoc.CreateElement("ShowImage")
                                      productNode.AppendChild(ShowImage)
                                      ShowImage.InnerText = "0"
                                  End If
                              Next
                          End If
                      Next
                  
                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups