zoukankan      html  css  js  c++  java
  • c#读取带命名空间的xml

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <GetAuthorizationCodeResponse xmlns="http://tempuri.org/">
          <GetAuthorizationCodeResult>boolean</GetAuthorizationCodeResult>
        </GetAuthorizationCodeResponse>
      </soap:Body>
    </soap:Envelope>
    var doc = new XmlDocument();
                var namespaceManager = new XmlNamespaceManager(doc.NameTable);
                namespaceManager.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
                namespaceManager.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
                namespaceManager.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");
                namespaceManager.AddNamespace("mynamespace", "http://tempuri.org/");
                doc.LoadXml(result.ResultData);
                var resultNode = doc.SelectSingleNode(@"soap:Envelope/soap:Body/mynamespace:GetAuthorizationCodeResponse/mynamespace:GetAuthorizationCodeResult", namespaceManager);
  • 相关阅读:
    WinCE 与通讯模块
    6174问题
    阶乘因式分解(一)
    三个数从小到大排序
    公约数和公倍数
    水仙花数
    韩信点兵
    5个数求最值
    求转置矩阵问题
    孪生素数问题
  • 原文地址:https://www.cnblogs.com/nanfei/p/2622034.html
Copyright © 2011-2022 走看看