添加xml结点的时候
var temp2 = temp1.Element("staticContent"); if (temp2 != null) { string str = "<remove fileExtension=".svg" /> <mimeMap fileExtension=".svg" mimeType="image/svg+xml" /> <remove fileExtension=".nupkg" /> <mimeMap fileExtension=".nupkg" mimeType="application/zip, application/octet-stream" /> <remove fileExtension=".webm" /> <mimeMap fileExtension=".webm" mimeType="video/webm" /> <remove fileExtension=".mp4" /> <mimeMap fileExtension=".mp4" mimeType="video/mp4" />"; temp2.AddFirst(XElement.Parse(str)); }
必须把多个节点从,拆分开来,逐个添加
解析xml字符串的时候
[Test] public void XmlTest() { string xml = "<Record ID="135" Key="CustomTableItemID" /> <Record ID="23" Key="CustomTableID" />"; XElement element = XElement.Parse(xml); Console.WriteLine(element); }
需要添加一个根结点,才能进行解析