/// <summary>
 /// 添加Xml节点
 /// </summary>
 private void AddNode(Xml xml, string key, object value)
 {
     if (key.SafeString().ToLower() == WechatpayConst.TotalFee)
     {
         xml.AddNode(key, value);
         return;
     }
     xml.AddCDataNode(value, key);
 }
Exemple #2
0
        public void TestAddNode_1()
        {
            //结果
            var result = new String();

            result.Append("<xml>");
            result.Append("<a>1</a>");
            result.Append("</xml>");

            //操作
            _xml.AddNode("a", "1");

            //验证
            Assert.Equal(result.ToString(), _xml.ToString());

            //输出结果
            _output.WriteLine(_xml.ToString());
        }
Exemple #3
0
        public static string ToXml(this IDictionary <string, object> builderData)
        {
            var xml = new Xml();

            foreach (var param in builderData)
            {
                xml.AddNode(param.Key, param.Value);
            }
            return(xml.Document.OuterXml);
        }
Exemple #4
0
        public void TestAddCDataNode_2()
        {
            //结果
            var result = new String();

            result.Append("<xml>");
            result.Append("<a>");
            result.Append("<![CDATA[1]]>");
            result.Append("</a>");
            result.Append("</xml>");

            //操作
            var parent = _xml.AddNode("a");

            _xml.AddCDataNode("1", parent);

            //验证
            Assert.Equal(result.ToString(), _xml.ToString());

            //输出结果
            _output.WriteLine(_xml.ToString());
        }