using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace read_xml
{
class Program
{
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
for (int i = 951; i < 952; i++)
{
string xmlpath = string.Format("E:/VOC2007/Annotations/{0}.xml",i);
//string xmlpath = "E:/VOC2007/Annotations/10.xml";
doc.Load(xmlpath);
//< folder >替换folder处</ folder >
XmlNode xn = doc.SelectSingleNode("//folder");
xn.InnerText = "trainset";
//< path > 替换path处 </ path >
XmlNode xn1 = doc.SelectSingleNode("//path");
xn1.InnerText = "E:/trainset/" + i + ".bmp";
doc.Save(xmlpath);
Console.WriteLine(i);
}
}
}
}
C#操作xml文件
最新推荐文章于 2024-07-22 14:16:57 发布