You could use Razor to traverse through your content structure and output it however you'd like...The sample sitemap file would probably be a good place to start, then change the HTML to whatever XML markup you'd like:
@inherits umbraco.MacroEngines.DynamicNodeContext
@{ @* Walk up the tree from the current page to get the root node *@ var rootNode = Model.AncestorOrself(1); }
@*Render the sitemap by passing the root node to the traverse helper*@ <div class="sitemap"> @traverse(@Model.AncestorOrSelf()) </div>
@*Helper method to travers through all descendants*@ @helper traverse(dynamic node){
@*If a MaxLevelForSitemap parameter is passed to the macro, otherwise default to 4 levels*@ var maxLevelForSitemap = String.IsNullOrEmpty(Parameter.MaxLevelForSitemap) ? 4 : int.Parse(Parameter.MaxLevelForSitemap);
@*Select visible children *@ var items = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);
@*If any items are returned, render a list *@ if (items.Any()) { <ul> @foreach (var item in items) { <li class="[email protected]"> <a href="@item.Url">@item.Name</a>
@*Run the traverse helper again *@ @traverse(item) </li> } </ul> } }
Umbraco WebAPI Content
I want to get access to the site content via the API
Home
-Section 1
-Page1-1
-Page1-2
-Section 2
-Page2-1
-Page2-2
I want to get an xml which i can then consume elsewhere (a seperate webforms application)
Thanks
Scott
You could use Razor to traverse through your content structure and output it however you'd like...The sample sitemap file would probably be a good place to start, then change the HTML to whatever XML markup you'd like:
was think web-api. but yes a simple Macro rendering XML would do the trick. thanks
is working on a reply...