Copied to clipboard

Flag this post as spam?

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


  • Byron Delgado 47 posts 70 karma points
    Feb 08, 2011 @ 00:07
    Byron Delgado
    0

    Save XML usercontrol wrapper, umbraco 4.6

    Hi, anyone knows if is possible to save xml by using the new dataeditor in the usercontrol wrapper in Umbraco 4.6. Or where could I get a tutorial about it.

    Thanks.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 08, 2011 @ 12:57
    Tom Fulton
    0

    Hi Byron,

    Yes, it's now possible to store XML with the UserControlWrapper in 4.6.  According to Tim's comments on this thread you just save the XML as a string or an XmlDocument and the wrapper will detect this and save as XML.  I've already tested by returning a string and it works great!

    -Tom

  • Byron Delgado 47 posts 70 karma points
    Feb 11, 2011 @ 17:58
    Byron Delgado
    0

    Hi Tom, thanks for this. Are you using XDocument .Net class for this? Do you have some code as example please. I appreciate the help.

    Byron

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 11, 2011 @ 18:36
    Tom Fulton
    0

    Hi Byron,

    No, I'm just saving a string formatted as XML and Umbraco handles the rest.

            public string _umbracoValue;
            public object value
            {
                get
                {
                    return txtXml.Text;
                }
                set
                {
                    _umbracoValue = value.ToString();
                }
            }

    txtXml just has a regular XML string, such as:

    <items>
     <item>
      <field1>Value1</field1>
      <field2>Value2</field2>
     </item>
     <item>
      <field1>Value1</field1>
      <field2>Value2</field2>
     </item>
    </items>

    ...and it just works!  Let me know if you can't get it going...

    -Tom

  • Byron Delgado 47 posts 70 karma points
    Feb 11, 2011 @ 19:32
    Byron Delgado
    0

    I was just about to post what I did, when I saw your response, This is what I did and yes it does work!

            private string _umbval;
            public object value
            {
                get { return GetXML(); }
                set { _umbval = value.ToString(); }
            }

            public static string GetXML()
            {
                XDocument xDoc = new XDocument(
                    new XDeclaration("1.0""utf-8""yes"),
                    new XElement("NewsItem",
                                 new XElement("Title"new XAttribute("html","http://www.Downloads/?=2&=2"),"Some title"),
                                 new XElement("Path""<![CDATA[<p>paragraph</p>]]")
                        )
                    );

                return xDoc.ToString();
            }



        return xDoc.ToString();
    }

     But I can get it to save CDATA content. This is what it produces

             <NewsItem>
                <Title html="http://www.Downloads/?=2&amp;=2">Some title</Title>
                <Path>&lt;![CDATA[&lt;p&gt;paragraph&lt;/p&gt;]]</Path>
              </NewsItem>

    Any ideas?

    Thanks

    Byron

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

    Continue discussion

Please Sign in or register to post replies