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))
                                {
                                    
                                }
                             
                            }
                        }
                    }  

 



posted @ 2016-04-12 09:06  时光吹老了好少年  阅读(488)  评论(0编辑  收藏  举报