Serialize a list of objects without the parent tag
This question already has an answer here:
You do not need to use serialize. Instead use xml linq :
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.IO;
using System.Net;
namespace ConsoleApplication73
{
class Program
{
const string FILENAME = @"c:temptest.xml";
static void Main(string[] args)
{
XDocument doc = XDocument.Load(FILENAME);
List<string> items = doc.Descendants("item").Select(x => (string)x).ToList();
}
}
}
链接地址: http://www.djcxy.com/p/65148.html
上一篇: 最有用的属性
下一篇: 序列化没有父标记的对象列表