I am having a XML file as:
As you can see from the above the no of Tags are changing with changing node level.
from which I want only:
1. Depthofprodstructure
2. Bomitemnumber
3. MaterialNumber
4. MaterialDescription
5. BomItemText1
6. ComponentQuantity
7. ValidFromDate
8. BomMaterialNumber
tags to be fetched and stored to the data base using DataSet string variables as I need further processing on the fetched value Row- wise. Currently I was using the following code:
if (txtXML.Text != null)
{
xmlFile = XmlReader.Create(txtXML.Text, new XmlReaderSettings());
ds.ReadXml(xmlFile);
}
else
{
MessageBox.Show("Please Choose a XML File First");
}
int i = 0;
connection.Open();
for (i = 0; i <= ds.Tables[3].Rows.Count - 1; i++)
{
Product_Name1 = ds.Tables[3].Rows[i].ItemArray[0].ToString();
but as the no of tags are varying I am facing a lot of problem to store the data.
I am very much new to XML reading and do not have idea about LINQ. So anyone who can give a good working example from the above data would be appreciated. Thanks in advance.
Replies
Know the answer? Post it — somebody with the same question will find it here.