Why don't you use the nodeFactory API if you're working in .NET?
var node = new Node(1234); //pass in the ID of the node that's your container node
foreach(Node n in node.Children.Where(x => x.GetProperty("MyExampleCustomField") == "1")) {
DropDownList.Items.Add(new ListItem(n.Id.ToString(), n.Id.ToString()));
}
Basically you load up your parent node, then use LINQ to filter the children for ones which match what you want.
That may not be 100% syntactically correct, but it's close and should get you started.
My bad on the post - I could (or maybe should) have included a bit more information, however didn't want to clutter the post with too much info ! Damned if you do, damned if you don't !!
Basically I have created an xml file of members and am trying to do get the data from that file. The structure of my XML file matches that of the standard Umbraco XML file - <node><data (with alias)>, etc
So I first load the XML doc and then I was wanting to apply a filter to get some specific node values. An excerpt of my XML file is below:
Convert specific nodes to a drop down list within a C# user control
Hey
I am wanting to filter an XML based on the value within a data field - the XML data I am traversing.
My c# code is
Whilst the page loads I am getting no output. So is anyone able to enlighten on :
Thanks
Nigel
Why don't you use the nodeFactory API if you're working in .NET?
var node = new Node(1234); //pass in the ID of the node that's your container node foreach(Node n in node.Children.Where(x => x.GetProperty("MyExampleCustomField") == "1")) { DropDownList.Items.Add(new ListItem(n.Id.ToString(), n.Id.ToString())); }
Basically you load up your parent node, then use LINQ to filter the children for ones which match what you want.
That may not be 100% syntactically correct, but it's close and should get you started.
Hi Slace
Thanks for your feedback.
My bad on the post - I could (or maybe should) have included a bit more information, however didn't want to clutter the post with too much info ! Damned if you do, damned if you don't !!
Basically I have created an xml file of members and am trying to do get the data from that file. The structure of my XML file matches that of the standard Umbraco XML file - <node><data (with alias)>, etc
So I first load the XML doc and then I was wanting to apply a filter to get some specific node values. An excerpt of my XML file is below:
Cheers
Nigel
Yee hah - have managed to figure it out . . .
Not sure the above will be totally useful for Umbraco-uvians but thought I'd post it as a conclusion to my wee challenge!
is working on a reply...