« OnResized, OnSizeChanged, OnLayout | Main | Windows Forms Order of Events »

XPath default namespace hack

/// TODO: Unsatisfying hack. The XPath treats an empty prefix as the null namespace (not the default namespace).

/// To find nodes that aren't in the null namespace, but are in the default namespace, an explicitly prefixed

/// namespace must be added to the namespace manager and used within the xpath string.

XmlNamespaceManager mgr = new XmlNamespaceManager(rowNode.OwnerDocument.NameTable);

mgr.AddNamespace("xpathnullns", rowNode.NamespaceURI);

XmlNode nextPageNode = rowNode.SelectSingleNode("xpathnullns:"+nextPageXPath, mgr);

 

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)