1

我有以下 XML 文档:

  <?xml version="1.0" encoding="utf-8" ?> 
  <appSettings>
  <Path> blahblahblah </Path> 
  <PathValue> blahblahblah </PathValue> 
  <domainName> blahblahblah </domainName> 
  <SuperUserEmail> blahblahblah </SuperUserEmail> 
  <SuperUserName> blahblahblah </SuperUserName> 
  <UserName> blahblahblah </UserName> 
  <Password> blahblahblah </Password>       
  <connectionstring>Data Source=ABC\SQLEXPRESS;Initial Catalog=mail;User ID=sa;Password=sa@</connectionstring> 
  </appSettings>

connectionstring现在我必须从节点中提取整个路径。我尝试使用以下代码:

XmlNodeList xnList = xml.SelectNodes("/appSettings/connectionstring");

但它似乎不起作用。知道如何使它工作吗?

4

1 回答 1

3

尝试

XmlNode node = xml.DocumentElement.SelectSingleNode("/appSettings/connectionstring");

string nodeval=node.InnerText;
于 2013-02-14T05:01:59.097 回答