Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jed 55 posts 80 karma points
    Oct 08, 2012 @ 14:56
    Jed
    0

    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)

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Oct 08, 2012 @ 15:47
    Chriztian Steinmeier
    0

    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

     

Please Sign in or register to post replies

Write your reply to:

Draft