且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用c#拆分XML文件

更新时间:2022-11-08 18:40:27

我认为循环可能是:

I think the loop could be:
String firstItem = lstVideos[0].InnerText;
for (int i = 1; i < lstVideos.Count; i+=2)
       {
           Response.Write(firstItem + " " + lstVideos[i].InnerText + " " + lstVideos[i+1] + " ");
           Response.Write("<br>");
       }


static void GetXMLDocument(int NoOfColumn)

{

string pathToXmlFile = @D:\ Manas \Prod.xml;

DataTable dt = new DataTable();

DataSet ds = new DataSet();

ds.ReadXml(pathToXmlFile);

if(ds.Tables.Count> 0)

{

dt = ds .Tables [0];

if(dt.Rows.Count> 0)

{

for(int i = 0; i < dt.Rows.Count; i ++)

{

string names = dt.Rows [i] [0] .ToString();

if(i> 0)Console.WriteLine();

string lines = names +;

for(int j = 1; j< ; dt.Columns.Count; j ++)//检查没有列

{

行+ = dt.Rows [i] [j] .ToString()+;

if(j%NoOfColumn == 0)//当它是你的最后阶段你没有列

{

Console.WriteLine(行);

lines = names +;
{

Console.WriteLine(行);

}

}

}

}

} Console.Read();

}





public static void GetXMLValue(int NoOfColumn)

{

XmlDocument xmldoc = new XmlDocument();

xmldoc.Load(@D:\ Manas \ProdNew.xml);



XmlNode nodeCol = xmldoc.DocumentElement.FirstChild;

XmlNode nodeRow = xmldoc.DocumentElement;

XmlNodeList lstRows = nodeRow.ChildNodes;

XmlNodeList lstColumns = nodeCol.ChildNodes;







for(int i = 0;我< lstRows.Count; i ++)

{

string names = lstRows [i] .InnerText.ToString();

if(i> 0)Console。 WriteLine();

string lines = names +;

for(int j = 1; j {

lines + = lstRows [i] .InnerText.ToString()+;

if(j%NoOfColumn == 0)//当它与你的最后阶段的列数相等时

{

Console.WriteLine(lines);

lines = names +;

}

if(j == lstColumns.Count - 1 && j%NoOfColumn!= 0)//在最后一栏检查

{

Console.WriteLine(lines);
}

}





}

Console.Read();

}
static void GetXMLDocument(int NoOfColumn)
{
string pathToXmlFile = @"D:\Manas\Prod.xml";
DataTable dt = new DataTable();
DataSet ds = new DataSet();
ds.ReadXml(pathToXmlFile);
if (ds.Tables.Count > 0)
{
dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string names = dt.Rows[i][0].ToString();
if (i > 0) Console.WriteLine(" ");
string lines = names + " ";
for (int j = 1; j < dt.Columns.Count; j++) //Check with no of columns
{
lines += dt.Rows[i][j].ToString() + " ";
if (j % NoOfColumn == 0)//When it is equla with your no of columns upto last stage
{
Console.WriteLine(lines);
lines = names + " ";
}
if (j == dt.Columns.Count - 1 && j % NoOfColumn != 0) //Check at last column
{
Console.WriteLine(lines);
}
}
}
}
} Console.Read();
}


public static void GetXMLValue(int NoOfColumn)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(@"D:\Manas\ProdNew.xml");

XmlNode nodeCol = xmldoc.DocumentElement.FirstChild;
XmlNode nodeRow = xmldoc.DocumentElement;
XmlNodeList lstRows = nodeRow.ChildNodes;
XmlNodeList lstColumns = nodeCol.ChildNodes;



for ( int i = 0; i < lstRows.Count; i++)
{
string names = lstRows[i].InnerText.ToString();
if (i > 0) Console.WriteLine("");
string lines = names + " ";
for (int j = 1; j {
lines += lstRows[i].InnerText.ToString() + " ";
if (j % NoOfColumn == 0)//When it is equla with your no of columns upto last stage
{
Console.WriteLine(lines);
lines = names + " ";
}
if (j == lstColumns.Count - 1 && j % NoOfColumn != 0) //Check at last column
{
Console.WriteLine(lines);
}
}


}
Console.Read();
}