In Razor, when I try to access the property, let's just call it "MyProperty", like this:
var xml = Model.MyProperty
It gives me an error telling me that MyProperty doesn't exist. When I just output the property like this:
@Model.GetPropertyValue("MyProperty")
It outputs the XML structure.
When I do this:
var xml = @Library.ToDynamicXml(artist.GetPropertyValue("MyProperty"));
It outputs:
MacroEngines.DynamicXml
So it seems that my datatypes XML is not stored as DynamicXml? Or? Also, when I try to loop through the DynamicXml after using the library method like this:
foreach(var item in xml.ArrayOfMyObject.MyObject)
{
}
It tells me that ArrayOfMyObject can't be found.
So, am I forced to parse through my XML the standard way in C# by using XDocument and XElement?
Any clarification on this is greatly appreciated! :-)
Grasping parsing of DynamicXml
Hi all,
I'm trying to get my head around parsing XML (and DynamicXml for that matter) in Razor.
I have a custom datatype which stores parsable XML in the Umbraco XML cache and the structure is as follows:
<ArrayOfMyObject> <MyObject> <ChildNode1>Text</ChildNode1> <ChildNode2>Text</ChildNode2> </MyObject> </ArrayOfMyObject>
In Razor, when I try to access the property, let's just call it "MyProperty", like this:
It gives me an error telling me that MyProperty doesn't exist. When I just output the property like this:
It outputs the XML structure.
When I do this:
It outputs:
So it seems that my datatypes XML is not stored as DynamicXml? Or? Also, when I try to loop through the DynamicXml after using the library method like this:
It tells me that ArrayOfMyObject can't be found.
So, am I forced to parse through my XML the standard way in C# by using XDocument and XElement?
Any clarification on this is greatly appreciated! :-)
Thanks in advance.
All the best,
Bo
Turns out the correct way of parsing the XML was this:
How do I add values to existing xml file in Umbraco?
Bookmarked
is working on a reply...