void GetXmlValue(int NoOffixedcolumn, int NoOfColumn)
{
string pathToXmlFile = @"D:\Manas\prodNew.xml";
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(pathToXmlFile);
XmlNode nodeCol = xmldoc.DocumentElement.FirstChild;
XmlNode nodeRow = xmldoc.DocumentElement;
XmlNodeList lstRows = nodeRow.ChildNodes;
XmlNodeList lstColumns = nodeCol.ChildNodes;
using (XmlWriter xmlwriter=XmlWriter.Create(@"D:\Manas\XMLFile.xml"))
{
xmlwriter.WriteStartDocument();
xmlwriter.WriteStartElement("Root");
for (int i = 0; i < lstRows.Count; i++)
{
string lines = "", fixColumns = "";
for (int k = 0; k < NoOffixedcolumn; k++)
{
fixColumns += lstRows[i].ChildNodes[k].InnerText + " ";
}
lines = fixColumns;
int counter = 1;
for (int j = NoOffixedcolumn; j < lstColumns.Count; j++)
{
lines += lstRows[i].ChildNodes[j].InnerText + " ";
if (counter % NoOfColumn == 0)
{ xmlwriter.WriteStartElement("Test");
Response.Write(lines + "<br />");
string[] words = lines.Split(' ');
for (int l = 0; l < words.Length-1; l++)
{
xmlwriter.WriteStartElement("C"+l);
xmlwriter.WriteValue(words[l]);
xmlwriter.WriteEndElement();
}
lines = fixColumns ;
xmlwriter.WriteEndElement();
}
if (j == lstColumns.Count - 1 && counter % NoOfColumn != 0)
{
xmlwriter.WriteStartElement("Test");
string[] words = lines.Split(' ');
for (int l = 0; l < words.Length-1; l++)
{
xmlwriter.WriteStartElement("C" + l);
xmlwriter.WriteValue(words[l]);
xmlwriter.WriteEndElement();
}
Response.Write(lines + "<br />");
xmlwriter.WriteEndElement();
}
counter += 1;
}
}
xmlwriter.WriteEndElement();
xmlwriter.WriteEndDocument();
}
}