linq to xml C#
2021-06-26 13:05
标签:vat message delete elements nts conf config current mes private string GetResponseErrorMsg(string transactionid, Dictionary XDocument doc = XDocument.Load(xmlpath); XElement errorMsgRoot = new XElement("MESSAGE", item.Value); CTODhead.Add(errorMsgRoot); } XElement CTODelete = (from CTO in rootLinq.Element("BODY").Element("CTOS").Elements() where CTO.Element("NAME").Value == item.Key select CTO).SingleOrDefault(); CTODelete.Add(errorMsgRoot); } return doc.ToString(); linq to xml C# 标签:vat message delete elements nts conf config current mes 原文地址:https://www.cnblogs.com/watchfluture/p/10107684.html
{
//key除了head 都是 CTO 加msg
string xmlpath = HttpContext.Current.Request.PhysicalApplicationPath + "//XML//Receive//" + transactionid + ".xml";
XElement rootLinq = doc.Root;
rootLinq.Name = "RESPONSE";
foreach (var item in errorMsg)
{
if (item.Key == "head")
{
XElement CTODhead = rootLinq.Element("HEADER");
if (CTODhead != null)
{
}
if (CTODelete != null)
{
CTODelete.Element("CONFIGURATION").Remove();
XElement errorMsgRoot = new XElement("MESSAGE", item.Value);
}
}