Desperate seeking answer to simple problem
-
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
-
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
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
-
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
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 -
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>
<ABased 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
-
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
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
-
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
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
-
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
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
-
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
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 enIf 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