我遇到了一個XML值的問題,它在我調試時將它加載到XML文檔中,但沒有找到值或要訪問的節點。這裏是xml。我想得到的價值是「活躍」。現在這個XML不是一個文件或任何東西,是作爲一個字符串傳遞的......(不能修改這個部分)只能訪問我可以創建函數來訪問它的類,但不能修改實際獲取值的代碼並且把它當作一個 「XML字符串」 這裏只閱讀XML節點
<Clients>
<BillingCycle>30</BillingCycle>
<Category>1</Category>
<Type>Admin</Type>
<AddressCat>3</AddressCat>
<ZipCodeCat>5</ZipCodeCat>
<ClientManager>
<UserID>5</UserID>
<ZPVal>1</ZPVal>
<DRY1>Test</DRY1>
<Active>1</Active>
</ClientManager>
</Clients>
C#代碼
public bool IsActive(int ClientID, int VassID)
{
bool isActive = false;
HelperClass helper = new HelperClass();
XmlDocument xml = new XmlDocument();
//at this point i can see the data was stored in the xml when debugging
xml.LoadXml(helper.GetClientXML(ClientID, VassID));
//have tried the following do not woerk
// XmlNode node = xml.SelectSingleNode ("/Clients/ClientManager/Active/text()");
XmlNode node = xml.SelectSingleNode("Clients/ClientManager/Active");
int isActiveVal = Convert.ToInt32(node.Value);
if (isActiveVal == 1)
{
isActive = true;
}
return isActive;
}