XML操作 之获取指定节点值
根据节点名称快速查找 指定节点值
using (TextReader stringReader = new StringReader(clearPassResponse)) { XmlReaderSettings xmlReaderSetting = new XmlReaderSettings(); xmlReaderSetting.ConformanceLevel = ConformanceLevel.Auto; xmlReaderSetting.IgnoreWhitespace = true; using (XmlReader xmlReader = XmlReader.Create(stringReader, xmlReaderSetting)) { if (xmlReader.ReadToFollowing("cas:username"))//括号里为 节点 name值 { string username = xmlReader.ReadElementString(); if (String.IsNullOrEmpty(username)) { } } } }