0
votes

Umbraco version 6.1, Visual Studio 2010

I'm trying to get a list of NewsArticles under the News folder in Umbraco i.e.

-News
--NewsArticle1
--NewsArticle2

My code is

var docType = "DocumentTypeName";
var parNode = Umbraco.TypedContentSingleAtXPath("//" + docType);

List<IPublishedContent> child = parNode.Children.ToList();

When this line is hit

var parNode = Umbraco.TypedContentSingleAtXPath("//" + docType);

It always gives me the wrong parNode (parent node that is) id. It finds the correct Doc Type (as if i change the name i get an error).

I've tried rebuilding, cleaning the project but it doesnt work. Other folders using the same code work so i dont know where or whats going wrong?

Any thoughts?

1

1 Answers

3
votes

If it's giving you the wrong content node, then you may have two or more content nodes of the same ContentType (docType).

TypedContentSingleAtXPath will return the first valid match only and ignore any subsequent nodes. You can verify the results by checking that the required node is the first one of it's type in the published cache (the ~/App_Data/Umbraco.config file).