zoukankan      html  css  js  c++  java
  • .Net C# 读取xml

    [TestMethod]
            public void Test3()
            {
                StringBuilder temp = new StringBuilder();
                temp.AppendFormat("<?xml version="1.0"?><Entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">");
                temp.AppendFormat("<Entity>");
                temp.AppendFormat("<EntityName>EntityName</EntityName>");
                temp.AppendFormat("<IdentifyType>IdentifyType</IdentifyType>");
                temp.AppendFormat("<IdentifyNumber>IdentifyNumber</IdentifyNumber>");
                temp.AppendFormat("<IssueCountry>IssueCountry</IssueCountry>");
                temp.AppendFormat("<Role>Role</Role>");
                temp.AppendFormat("<SourceRequest>{0}</SourceRequest>", SourceRequestEnum.FCA);
                temp.AppendFormat("</Entity>");
                temp.AppendFormat("<Entity>");
                temp.AppendFormat("<EntityName>EntityName</EntityName>");
                temp.AppendFormat("<IdentifyType>IdentifyType</IdentifyType>");
                temp.AppendFormat("<IdentifyNumber>IdentifyNumber</IdentifyNumber>");
                temp.AppendFormat("<IssueCountry>IssueCountry</IssueCountry>");
                temp.AppendFormat("<Role>Role</Role>");
                temp.AppendFormat("<SourceRequest>{0}</SourceRequest>", SourceRequestEnum.FCA);
                temp.AppendFormat("</Entity>");
                temp.AppendFormat("</Entities>");
    
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(temp.ToString());
                XmlNodeList rows = xmlDoc.SelectNodes("Entities/Entity");
    
                string sourceRequest = string.Empty;
                if (rows.Count > 0)
                {
                    foreach (XmlNode row in rows)
                    {
                        XmlNode node = row.SelectSingleNode("./SourceRequest");
                        sourceRequest = (node == null ? string.Empty : node.InnerText.Trim());
                        if (!string.IsNullOrEmpty(sourceRequest))
                        {
                            break;
                        }
                    }
                }
            }
  • 相关阅读:
    libyuv 代码结构分析,借用其NEON/ARM64优化代码
    Android 交叉编译 IPerf3
    Android Change TCP Congestion Control
    Unpack & Repack Android system.img & data.img
    Android can only be built by versions 3.81 and 3.82
    Build Android Kernel && Kernel Module
    换行符
    python之%s、%d、%f的使用
    Python+selenium 实现不定位元素,输入enter键
    进程间通信 (IPC) 方法总结(三)
  • 原文地址:https://www.cnblogs.com/hofmann/p/11346990.html
Copyright © 2011-2022 走看看