Any idea why the following simple GetXmlNodeByXPath implimentation never works? The node name is correct, but no matter what xpath is used 'no nodes' are found or data returned...
string GetNodeData() { string data = ""; System.Xml.XPath.XPathNodeIterator iter = umbraco.library.GetXmlNodeByXPath("/root/node[@nodeName = 'Intranet Home']"); if (iter.MoveNext()) { data = iter.Current.InnerXml; } else { data = "no nodes"; } return (data); }
Xpaths tried so far include (all with values known to be correct):
GetXmlNodeByXPath never works
Any idea why the following simple GetXmlNodeByXPath implimentation never works?
The node name is correct, but no matter what xpath is used 'no nodes' are found or data returned...
string GetNodeData() {
string data = "";
System.Xml.XPath.XPathNodeIterator iter = umbraco.library.GetXmlNodeByXPath("/root/node[@nodeName = 'Intranet Home']");
if (iter.MoveNext()) {
data = iter.Current.InnerXml;
} else {
data = "no nodes";
}
return (data);
}
Xpaths tried so far include (all with values known to be correct):
'//root'
'/root/node[@nodeName = 'Known Name']'
'//node[@id=1101]/'
'//KnownNode[@isDoc]'
'//node [string(./data [@alias = 'FirstName']) = 'Employee']'
and many more
(Umbraco 4.6.1, ASP 4,, IIS7.5)
Hi Jed,
I'd guess it's because of some "new vs. old" XMLschema confusion maybe...
The above expressions would be written like this in the new Schema (which was effective from Umbraco 4.5.1, I think):
//root or /root
/root/*[@nodeName = 'Known Name']
//*[@id = 1101] or //*[@isDoc][@id = 1101]
//KnownNode[@isDoc] (<< @isDoc only exist in the new schema)
//*[@isDoc][FirstName = 'Employee']
(In the new schema, the isDoc attribute is used to determine DocumentTypes, which were before just named "node")
/Chriztian
is working on a reply...