李维强-15级 发表于 2017-8-27 15:51:51

XML操作

http://www.cnblogs.com/shenzhoulong/archive/2011/01/27/1946532.html

http://www.cnblogs.com/xiaofeixiang/p/4067791.html
其实只要一个XMLElement就可以了

李维强-15级 发表于 2017-11-16 12:05:13

本帖最后由 李维强-15级 于 2017-11-17 22:34 编辑

由于微信支付通知的内容是XML的类似如下格式,所以需要相关的东西去解析

微信付款通知返回如下信息
<xml>
<appid><!]></appid>
<attach><!]></attach>
<bank_type><!]></bank_type>
<cash_fee><!]></cash_fee>
<fee_type><!]></fee_type>
<is_subscribe><!]></is_subscribe>
<mch_id><!]></mch_id>
<nonce_str><!]></nonce_str>
<openid><!]></openid>
<out_trade_no><!]></out_trade_no>
<result_code><!]></result_code>
<return_code><!]></return_code>
<sign><!]></sign>
<time_end><!]></time_end>
<total_fee>100</total_fee>
<trade_type><!]></trade_type>
<transaction_id><!]></transaction_id>
</xml>



下面给一个示例,做到读取相关内容

private int ReadXml()
      {
            string responseInfo = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
                              + @"<xml>
                                        <appid>
                                          <!]>
                                        </appid>
                                    </xml>";
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseInfo);
            string xpathChiefComplaint = "/xml/appid";

            XmlNode xnChiefComplaint = doc.SelectSingleNode(xpathChiefComplaint);

            string nodeValue = xnChiefComplaint.InnerText;
      }
以上代码的 nodeValue就是wx8888888888888888
页: [1]
查看完整版本: XML操作