For each of those nodes, I need to access the node ID's contained in a multi content picker.
For each of those node ID's, I need to retrieve a property form that node and append it to a string.
List<Node> nodes = uQuery.GetNodesByXPath("//*[@id = '1343' or @id = '1103']//*"); int sort = 0; foreach (Node item in nodes) { string propertyList = ""; //Here is where I need help the rest is pseudo code List<ContentID> ids = Node.getProperty("NodePicker") foreach (ContentID id in ids) { Node newContent = new Node(id); propertyList += newContent.getProperty("associatedProperty").Value + ","; } }
Sorry a bit late to aswer this, but thought I'd mention that uQuery also has methods to return node collections from the stored Xml / Csv values (in this case the "NodePicker" property).
List<Node> nodes = uQuery.GetNodesByXPath("//*[@id = '1343' or @id = '1103']//*"); List<Node> pickedNodes; StringBuilder stringBuilder = new StringBuilder();
foreach(Node node in nodes) { pickedNodes = uQuery.GetNodesByXml(node.GetProperty<string>("NodePicker");
Need some help traversing nodes in C#
Here's the situation:
I have List of nodes retreived using uquery.
For each of those nodes, I need to access the node ID's contained in a multi content picker.
For each of those node ID's, I need to retrieve a property form that node and append it to a string.
List<Node> nodes = uQuery.GetNodesByXPath("//*[@id = '1343' or @id = '1103']//*");int sort = 0;
foreach (Node item in nodes)
{
string propertyList = "";
//Here is where I need help the rest is pseudo code
List<ContentID> ids = Node.getProperty("NodePicker")
foreach (ContentID id in ids) {
Node newContent = new Node(id);
propertyList += newContent.getProperty("associatedProperty").Value + ",";
}
}
Any help would be appreciated.
Thanks!
Hi,
Are you storing your MNTP values as XML or CSV? If XML, something like this should work (not tested):
(using uComponents.Core.uQueryExtensions)
string nodesList = item.GetPropertyValue<string>("NodePicker");
XmlDocument xd = new XmlDocument();
xd.LoadXml(nodesList);
foreach (XmlElement value in xd.SelectNodes("/MultiNodePicker/nodeId"))
{
Node newContent = new Node(Convert.ToInt32(value.InnerText));
propertyList += newContent.GetPropertyValue<string>("associatedProperty");
}
-Tom
If you're storing as CSV, you can use something like:
string[] nodesList = item.GetPropertyValue("NodePicker")<string>.Split(','); foreach (string value in nodesList) { Node newContent = new Node(Convert.ToInt32(value)); propertyList += newContent.GetPropertyValue("associatedProperty"); }Hi,
Sorry a bit late to aswer this, but thought I'd mention that uQuery also has methods to return node collections from the stored Xml / Csv values (in this case the "NodePicker" property).
If the MNTP is storing a csv, then:
pickedNodes = uQuery.GetNodesByXml(node.GetProperty<string>("NodePicker");can be replaced with:
pickedNodes = uQuery.GetNodesByCsv(node.GetProperty<string>("NodePicker)";is working on a reply...
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.