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;
    }

posted @ 2012-05-07 09:41  yqie  阅读(9750)  评论(0编辑  收藏  举报