SelectSingleNode ASP.NET XML的小问题
ArrayList list = new ArrayList();
XmlDocument xdoc = new XmlDocument();
xdoc.Load(Server.MapPath( "../dbGuest.xml "));
string inName = TextBox1.Text;
XmlNode userNode = xdoc.DocumentElement.SelectSingleNode( "User ");
if (userNode.ChildNodes.Count > 0)
{
foreach (XmlNode ele in userNode.ChildNodes)
{
list.Add(ele.InnerText);
}
if (list.Count > 0)
{
DataList1.DataSource = list;
DataBind();
}
}
else
Response.Write( "XML读取错误... ");
以上代码,执行到 XmlNode userNode = xdoc.DocumentElement.SelectSingleNode( "User ");
时候,userNode = null, 不知道问题出在哪里,还请高手指教
xml文件:
<?xml version= "1.0 " standalone= "yes "?>
<dbGuest xmlns= "http://tempuri.org/dbGuest.xsd ">
<User>
<Name> shaoazhd </Name>
<City> beijing </City>
<Email> sss@22.net </Email>
<Message> afsa </Message>
</User>
<User>
<Name> zhangsan </Name>
<City> shanghai </City>
<Email> zhangsna@322.net </Email>
<Message> sss </Message>
</User>
<User>
<Name> sss </Name>
<City> ss </City>
<Email> ss@22.net </Email>
<Message> asfdasfd </Mes