Copied to clipboard

Flag this post as spam?

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


  • Craig O'Mahony 363 posts 917 karma points
    Jan 15, 2014 @ 15:15
    Craig O'Mahony
    0

    Listing xPath checkboxlist items

    Hi all,

    I've got an Xpath Checkboxlist property on my templates which lists a series of speakers (//Speaker [@isDoc and string(east) = '1'] is the xPath Expression) this lists the speakers as expected when I'm creating the content but I can't seem to extract the node id's that have been selected in a c# usercontrol. I've searched everywhere for examples but all relate to XSLT and Razor and I can't get these to work. If I select CSV as the storage type the below will get me a string but its not comma separated!!!

                if (myNode.HasProperty("xpather"))
                {
                    string[] myCSVArray = myNode.GetProperty("xpather").Value.Split(',');
                    foreach (string myCSVNode in myCSVArray)
                    {
                        litSpeakers.Text += myCSVArray.ToString();
                    }
                }

    Any idea anyone??

    Thanks,

    Craig

  • Craig O'Mahony 363 posts 917 karma points
    Jan 22, 2014 @ 10:22
    Craig O'Mahony
    100

    Eventually got this sorted using:

            foreach (Node myNode in childNodes)

            {

                string dataValue = myNode.GetProperty("speakers").Value.ToString();

     

                XmlDocument xmlDoc = new XmlDocument();

                xmlDoc.LoadXml(dataValue);

                foreach (XmlNode itemnode in xmlDoc.DocumentElement)

                {

                    litNode.Text += itemnode.InnerText;

                    Node myUmbracoNode = new Node(Int32.Parse(itemnode.InnerText));

                    litNode.Text += myUmbracoNode.Name + "<br/>";

                }

    }

  • 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.

Please Sign in or register to post replies