Copied to clipboard

Flag this post as spam?

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


  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 21, 2012 @ 16:26
    Peter Cort Larsen
    0

    Related links loop

    Hi,

     

    I have a related links datatype on a document.

    In c# i want to loop other the items added to the related links property, so they can be added to an xml output used in a /base call.

     

    My code so far.

    string xml = @"<pages xmlns=""dt"" xmlns:dt=""dt"">";
    Document doc = new Document(mainid);
    if (doc.HasChildren)
    {
    Document[] children = doc.Children;

    foreach (Document childDoc in children)
    {
    string PropertyData = uQuery.GetDocument(childDoc.Id).GetProperty<string>("checkboxOptions");
    //the below seems to be empty
    Property PropertyDataLinks = childDoc.getProperty("relatedLinks");

    xml += "<page title=\"" + childDoc.Text + "\" nodeid=\"" + childDoc.Id + "\">";

    foreach (var line in PropertyData.Split('\n'))
    {
    xml += "<node>" + line.TrimEnd() + "</node>";
    }

    //this isnt generating an output
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(new StringReader(PropertyDataLinks));
    XmlNodeList nodeList = xmlDoc.SelectNodes("/links/link");
    foreach (XmlNode node in nodeList)
    {
    xml += "<links>" + node.Name + "</links>";
    }

    xml += "</page>";
    }
    }
    xml += "</pages>";
Please Sign in or register to post replies

Write your reply to:

Draft