-1
我必須讀取xml文件。我做到了,但我遇到了問題。 我有這樣的XMLXml讀取器讀取標籤
<?xml version="1.0" encoding="windows-1254" ?>
- <Xm>
- <Products>
<Product_No>NT-7</Product_No>
<Stok>1</Stok>
<Product_Details>something</Product_Details>
<Desi>0,2</Desi>
- <Variant>
<VariantAd>size</VariantAd>
<Options>68 cm</Options>
</Variant>
</Products>
- <Products>
<Product_No>NT-15</Product_No>
<Stok>1</Stok>
<Product_Details>something</Product_Details>
<Desi>0,2</Desi>
- <Variant>
<VariantAd>size</VariantAd>
<Options>68 cm</Options>
<Options>74 cm</Options>
</Variant>
</Products>
</Xm>
我可以讀everyting,但我的問題是我不能單獨選擇。
<Options>68 cm</Options>
<Options>74 cm</Options>
我不能一起閱讀。我需要一起閱讀並以字符串形式加入。
System.Xml.XmlNodeList lst = root.GetElementsByTagName("Product_No");
foreach (System.Xml.XmlNode n in lst)
{
Product_No.Add(n.InnerText);
}
lst = root.GetElementsByTagName("Stok");
foreach (System.Xml.XmlNode n in lst)
{
Stok.Add(n.InnerText);
}
lst = root.GetElementsByTagName("Product_Details");
foreach (System.Xml.XmlNode n in lst)
{
Product_Details.Add(n.InnerText);
}
lst = root.GetElementsByTagName("Options");
foreach (System.Xml.XmlNode n in lst)
{
Options.Add(n.InnerText);
}
我該如何閱讀和加入他們?