请问怎样读写xml文件
如题
------解决方案--------------------http://www.cnblogs.com/qingfengyang/archive/2009/10/27/1590776.html
------解决方案--------------------Linq2Xml
------解决方案--------------------http://topic.csdn.net/u/20100827/14/b841a725-f0ce-49ad-857d-c24c8296e350.html?seed=2069456965&r=68027897
------解决方案--------------------看MSDN吧,最新的技术是LinqtoXML.
构造XDocument
http://msdn.microsoft.com/zh-cn/library/system.xml.linq.xdocument.aspx
写xml
http://msdn.microsoft.com/zh-cn/library/bb345830.aspx
读xml
http://msdn.microsoft.com/zh-cn/library/bb343181.aspx
------解决方案--------------------
static void Main(string[] args)
{
XDocument xdoc = XDocument.Load("mapping.xml");
Dictionary<string,List<string>> hm = new Dictionary<string,List<string>>();
hm = (from node in xdoc.Root.Elements("mapping").ToDictionary(c => c.Attribute("listName").Value, c => (from cc in c.Elements("request") select cc.Attribute("val").Value).ToList()) select node).ToDictionary(k => k.Key, k => k.Value);
foreach (var k in hm.Keys)
{
Console.WriteLine(k);
foreach (var v in hm[k])
{
Console.WriteLine("\t" + v);
}
}
}