xml格式封装数据
Posted zkbfighting
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml格式封装数据相关的知识,希望对你有一定的参考价值。
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格式封装数据的主要内容,如果未能解决你的问题,请参考以下文章
AJAX 响应:数据(JSON、XML)还是 HTML 片段? [关闭]
java 调用cxfWebService 接口返回类型是xml格式数据显示在jsp页面中该如何做到