<?xml version="1.0" encoding="GB2312" ?>
<root result="0" /> 我怎么把result的值取出来啊<?xml version="1.0" encoding="GB2312" ?>
<root null />另外什么都没有的时候返回一个空值,这种情况下,又怎么处理呢?
<root result="0" /> 我怎么把result的值取出来啊<?xml version="1.0" encoding="GB2312" ?>
<root null />另外什么都没有的时候返回一个空值,这种情况下,又怎么处理呢?
<root /> ";
System.Xml.XmlDocument dom = new System.Xml.XmlDocument();
dom.LoadXml(str);
System.Xml.XmlNode node = dom.SelectSingleNode("//root");
if (node != null && node.Attributes["result"] !=null)
{ Response.Write(node.Attributes["result"].Value);
}
string str = @"<?xml version=""1.0"" encoding=""GB2312"" ?>
<root result=""0""/> ";
Regex reg = new Regex(@"<root result=""([^""]*?)""");
MatchCollection ms = reg.Matches(str);
if (ms.Count > 0)
{
Response.Write(ms[0].Result("$1"));
}
string resultStr = Regex.Match(yourStr, "<root\\s+result=\"(.+?)\"\\s+/>", RegexOptions.IgnoreCase).Groups[1].Value;