我有一個XPath查詢對我來說看起來很合適,但沒有返回任何結果。我的屬性搜索XPath查詢有什麼問題
它正在對測試的XML文檔:
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Deployment.Parts>
<AssemblyPart x:Name="foo" Source="foo.dll" />
</Deployment.Parts>
</Deployment>
代碼:
Xml = new XmlDocument();
Xml.LoadXml(text);
Manager = new XmlNamespaceManager(Xml.NameTable);
//use constants for namespaces to make more readable
Manager.AddNamespace("a", NS_DEPLOYMENT_2007); //use 'a' for default namespace here so xpath is easier
Manager.AddNamespace("x", NS_XAML_2006);
string xpath="//a:Deployment.Parts/a:AssemblyPart[@a:Source='foo.dll']";
var tmp = Xml.SelectNodes(xpath, Manager);
什麼是錯在這裏我的XPath查詢?