首页 > 其他 > 详细

xml格式封装数据

时间:2020-04-26 18:53:55      阅读:95      评论:0      收藏:0      [点我收藏+]
 xml层级关系
XDocument obj = new XDocument(new XDeclaration("1.0", "utf-8", "yes")); //构造根节点 obj.Add(new XElement("request", new XElement("criteriaList", new XElement("criteria", new XElement("warehouseCode", warehousecode), new XElement("ownerCode", whse), new XElement("itemCode", sku.sku), new XElement("itemId", "")))));

XmlDocument doc = new XmlDocument();
doc.LoadXml(obj.ToString());

 var obj = new JObject
                    {
                        {"?xml",new JObject
                            {
                                {"@version","1.0" },
                                {"@encoding","utf-8"}
                            }
                        },
                        { "request", new JObject
                            {
                                {"actionType","add"},
                                {"warehouseCode", warehousecode},
                                {"ownerCode",  whse},
                                {"supplierCode", ""},
                                {"supplierName", "" },
                                { "item", j },
                                {"extendProps", new JObject
                                    {
                                        {"key1", "" },
                                        {"key2", "" },
                                        {"key3", "" },
                                        {"key4", "" },
                                        {"key5", "" }
                                    }
                                }
                            }
                        }
                    };
XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(JsonConvert.SerializeObject(obj));

 

xml格式封装数据

原文:https://www.cnblogs.com/ZkbFighting/p/12781311.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!