c# 得到 XML的节点值和属性值


System.Xml.XmlNode node

//得到XML的属性值

node.Attributes["HotelCode"].Value;

 

node["BasicProperty"]["Address"]

得到节点下面的节点内容值

 

得到节点的内容

  /// <summary>
    ///得到节点值的内容,如果为Null 返回 ""
    /// </summary>
    /// <param name="node">得到指定节点的值</param>
    /// <returns></returns>   
    public static string GetXmlNodeInnerText(System.Xml.XmlNode node)
    {
        string Result = "";
        if (node != null)
        {
            Result = node.InnerText;
        }
        else
        {
            Result = "";
        }
        return Result;
    }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM