Copied to clipboard

Flag this post as spam?

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


  • Nathan Woulfe 447 posts 1665 karma points MVP 5x hq c-trib
    Oct 11, 2012 @ 06:04
    Nathan Woulfe
    0

    umbraco.library.GetXmlAll() only returning root

    Hi all

    I'm trying to grab the site xml using GetXmlAll(), but only seem to get one node back, being root. Wanting to parse the xml in a handler, but can't seem to get it out.

    The call is pretty simple

    var nodes = umbraco.library.GetXmlAll()

    so I'm not sure what's going wrong. Doing similar in a simple macro returns the same, just root.

    Any ideas?

    ta

    Nathan

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Oct 11, 2012 @ 08:18
    Chriztian Steinmeier
    0

    Hi Nathan,

    You get the complete XML - but there is only ever a single root element in any valid XML file, and that's the one you get from that extension method - to access the rest you should use XPath - I'm sure if you explicitly say XPathNodeIterator or XPathNavigator in stead of plain var, you will get IntelliSense on the nodes variable, so you can do nodes.SelectSingleNode("*[@isDoc]") etc. on it to grab the specific nodes that you're looking for.

    /Chriztian 

  • Nathan Woulfe 447 posts 1665 karma points MVP 5x hq c-trib
    Oct 11, 2012 @ 08:37
    Nathan Woulfe
    0

    Hi Chriztian

    Thanks for that, I think I was just confusing myself - I'd tried using while(nodes.MoveNext()) with no luck.

    Ended up using uQuery.GetPublishedXml and a bit of LINQ to get what I needed..

     

    ta

    Nathan

Please Sign in or register to post replies

Write your reply to:

Draft