Copied to clipboard

Flag this post as spam?

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


  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Mar 10, 2010 @ 09:26
    Sebastiaan Janssen
    0

    Alternative to content.Instance.XmlContent

    So I am getting an XmlNodeList by doing this:

    var panoramaNodes = content.Instance.XmlContent.SelectNodes("//node [@nodeTypeAlias = 'Panorama' and data[@alias = 'mailSentDate'] != '']");

    This works great and I am happily working with the nodes that get returned. So far, so good.

    However, I saw a tweet by Niels a few weeks ago of him wanting to break the possibility to directly call content.Instance. I always knew I was not really supposed to do that, but anything that can be abused will be abused, right? ;-)

    So, here's my question: how SHOULD I be getting the same result (an XmlNodeList)? I've been looking for sample code, using the nodeFactory, but I can't find an example that works for me. Can someone please show me how to rewrite the above code?

    Many thanks!

  • Aaron Powell 1708 posts 3044 karma points c-trib
    Mar 10, 2010 @ 09:47
    Aaron Powell
    0

    Got source of those tweets? I actually added an exposure of the XML cache within the UmbracoContext which is more useful in v4.1. But I exposed it as a XDocument, cuz LINQ to XML is more awesome ;)

  • Stephan Lonntorp 195 posts 212 karma points
    Mar 10, 2010 @ 10:19
    Stephan Lonntorp
    0

    I think he decided against removing it after all, but I remember that tweet too.

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Mar 10, 2010 @ 10:48
    Sebastiaan Janssen
    1

    Niels' original tweet and his promise to "behave" (as if! :p) later.

    Now answer the original question, please. ;-) lol

  • Stephan Lonntorp 195 posts 212 karma points
    Mar 10, 2010 @ 10:56
    Stephan Lonntorp
    0

    What's wrong with your solution? Looks neat to me. Unless you want to use LINQ2Umbraco in 4.1 that is. That'll look even better.

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Mar 10, 2010 @ 17:18
    Sebastiaan Janssen
    0

    I just really want a clear example of something using the nodeFactory, as I can't seem to find any. Also, we're not "supposed" to call content.Instance directly anyway, so I would like a good alternative.

    Mostly this is just something I want for documentation of best practices.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies