Copied to clipboard

Flag this post as spam?

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


  • Eran Meir 401 posts 543 karma points
    May 08, 2011 @ 19:04
    Eran Meir
    0

    Xpath problem

    i have the following content

    Home
         Categories
               Category 1
               Category 2

    my Model is "Home" node, i want to display all the categories
    i'm trying to do the follwing 


    @Model.XPath("/Categories").Descandents("Category")

    but i get the error 

    Error loading Razor Script ProjectsList.cshtml
    XPath returned no nodes
    a better solution will be welcomed :)

  • Toni Becker 146 posts 425 karma points
    May 08, 2011 @ 20:31
    Toni Becker
    0

    do it with the normal syntax

    @foreach(var cat in Model.Children)
    {
    @cat.categories
    }

  • Eran Meir 401 posts 543 karma points
    May 09, 2011 @ 11:32
    Eran Meir
    0

    your answer doesn't make sense to me
    i have only one node with categories as children.

  • Jonas Eriksson 930 posts 1825 karma points
    May 09, 2011 @ 12:04
    Jonas Eriksson
    0

    Hi, do you specifically want to use XPath? Otherwise :

    @foreach(var cat in Model.Categories)
    {
    @cat.Name
    }


  • Eran Meir 401 posts 543 karma points
    May 09, 2011 @ 12:18
    Eran Meir
    0

    i get Model.Categories as DynamicNodeList, so i needed to add .First() to the "Model.Categories", any elegant solution?

Please Sign in or register to post replies

Write your reply to:

Draft