I have a textstring array with 3 columns, width, height and format as pictured below
When I try i to get the values through razor using:
@Model.NodeById(imageBankNodeId).dimensions
I get the following error:
Error Loading Razor Script (file: Image Bank Search) Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String arg) at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at System.Xml.XmlDocument.LoadXml(String xml) at uComponents.Core.DataTypes.TextstringArray.TextstringArrayModelBinder.Init(Int32 CurrentNodeId, String PropertyData, Object& instance) at umbraco.MacroEngines.DynamicNode.TryCreateInstanceRazorDataTypeModel(Guid dataType, Type dataTypeType, String value, Object& result) at umbraco.MacroEngines.DynamicNode.TryGetMember(GetMemberBinder binder, Object& result) at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at ASP._Page_macroScripts_imageBankSearch_cshtml.Execute() in c:\inetpub\wwwroot\Logitrans\macroScripts\imageBankSearch.cshtml:line 175 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) at System.Web.WebPages.WebPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
Hm, I can't actually seem to find it in the xml. The property is attached to a media node, whose ID doesn't seem to appear in the umbraco.config file.
EDIT:
I managed to dig out the values from the database. I've tried recreating the umbraco.config file a number of times but the values still don't appear in the xml, and neither does the media node id.
Ah, I didn't realize you were doing this in Media and not Content. This actually makes sense because I've seen a similar issue, it seems that Razor doesn't load XML properly for media properties. I tried to find a quick workaround but nothing came up, I might see if I can look into this more later as I'm curious.
As a temporary workaround you might use XSLT or try disabling uComponents Razor ModelBinding (though not sure if this will fix the issue completely, the data still may not be in a usable form).
Textstring array datatype throws xml exception
I have a textstring array with 3 columns, width, height and format as pictured below
When I try i to get the values through razor using:
I get the following error:
If I try getting the value ike this:
the output is all the data concatenated together like so
I'm running uComponents v4.0, any suggestions?
Hi Mikkel,
Can you try finding the property in umbraco.config and paste the full XML here? Sounds like it might be formatted incorrectly for some reason
-Tom
Hm, I can't actually seem to find it in the xml. The property is attached to a media node, whose ID doesn't seem to appear in the umbraco.config file.
EDIT:
I managed to dig out the values from the database. I've tried recreating the umbraco.config file a number of times but the values still don't appear in the xml, and neither does the media node id.
This is whats in the database:
Hi Mikkel,
Ah, I didn't realize you were doing this in Media and not Content. This actually makes sense because I've seen a similar issue, it seems that Razor doesn't load XML properly for media properties. I tried to find a quick workaround but nothing came up, I might see if I can look into this more later as I'm curious.
As a temporary workaround you might use XSLT or try disabling uComponents Razor ModelBinding (though not sure if this will fix the issue completely, the data still may not be in a usable form).
- Tom
Hey Tom, thanks for looking into it. I ended up using a pretty crude workaround, but it'll do for now.
Entered a delimiter into the data so i could split the string and have it sort of work till i find a better solution.
is working on a reply...