<Products>
<Product>
<Product_code>
<![CDATA[ 9.077 ]]>
</Product_code>
<Price2>799.99</Price2>
<variants>
<variant>
<spec name="Renk">White</spec>
<productCode>
<![CDATA[ 9.0771933 ]]>
</productCode>
<picture>
<![CDATA[ image/data/resimler/hakiki-deri-cz-saracli-topuklu-kadin-cizme-8316.jpg ]]>
</picture>
<picture>
<![CDATA[ image/data/resimler/hakiki-deri-cz-saracli-topuklu-kadin-cizme-8314.jpg ]]>
</picture>
</variant>
<variant>
<spec name="Renk">Black</spec>
<productCode>
<![CDATA[ 9.0771734 ]]>
</productCode>
<picture>
<![CDATA[ image/data/resimler/hakiki-deri-cz-saracli-topuklu-kadin-cizme-8316.jpg ]]>
</picture>
<picture>
<![CDATA[ image/data/resimler/hakiki-deri-cz-saracli-topuklu-kadin-cizme-8314.jpg ]]>
</picture>
</variant>
</variants>
</Product>
</Products>
This is my XML sample:
It's about products with Product Code
, Color
, Variant Code
, and Picture
I want to get first the Product_code
s then all Variant
s of that Product_code
For example:
Product_code: 9.077
Price2: 799.99
Renk: White
productCode: 9.0771933
picture1: link1
picture2: link2
Renk: Black
productCode: 9.0771734
picture1: link1
picture2: link2
XmlDocument xmlDoc = new XmlDocument();
XmlDocument xDoc = new XmlDocument();
xmlDoc.Load("eticaret.xml");
XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/Products/Product");
foreach (XmlNode tu in xmlDoc.SelectNodes("/Products/Product"))
{
MessageBox.Show("tu = " + tu.SelectSingleNode("Product_code").InnerText);
foreach (XmlNode tuv in tu.SelectNodes("/Products/Product/variants/variant"))
{
MessageBox.Show("tuv = " + tuv.SelectSingleNode("productCode").InnerText + " - " + tuv.SelectSingleNode("spec[@name='Renk']").InnerText;
}
}
I used this code
It actually works but: The first gives the information of the first part The following shows only the product variants It no longer shows the first information