Copied to clipboard

Flag this post as spam?

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


  • Fengelz 106 posts 221 karma points
    Aug 28, 2009 @ 15:10
    Fengelz
    0

    Using XPathNodeIterator to generate xml in Codebehind

    I'm pretty new to this whole Xpath Xquery thingy. so please forgive this newbie question.

    I have a function in a class and I wish to get a specific node from the content by fx and attribute.

    My question is: how do you get the xml output from a nodeiterator?

    I have a function:

    private string GetXmlString()
    {
    XPathNodeIterator n = umbraco.library.GetXmlNodeByXPath("//node [@id = 1079]");
    return n.Current.InnerXml;
    }

    this always generates the full site document.

    How does one go about and get xml in this manner?

    best regards Sune Fengel

  • Chris Koiak 700 posts 2626 karma points
    Aug 29, 2009 @ 09:21
    Chris Koiak
    0

    Hi Fenglez

    Try

    private string GetXmlString()
    {
            XPathNodeIterator n = umbraco.library.GetXmlNodeByXPath("//node [@id = 1079]");
    n.MoveNext();
            return n.Current.InnerXml;
    }

    The XPathNodeIterator may still be positioned at the root node.

    Cheers,

    Chris

  • Fengelz 106 posts 221 karma points
    Aug 31, 2009 @ 16:24
    Fengelz
    0

    sweet :)

    thanks for the pointer, works like a charm.

    - Sune

Please Sign in or register to post replies

Write your reply to:

Draft