Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi
What is the best approach to read in and XML file and transform to HTML.
I want to use Razor and not XSLT
Thanks
This is how I managed to solve this.
FileStream xmlFS = new FileStream(Server.MapPath("/xml/timeline.xml"), FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read);
System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings(); settings.XmlResolver = null; settings.DtdProcessing = System.Xml.DtdProcessing.Parse; // Create the XmlReader object. System.Xml.XmlReader reader = System.Xml.XmlReader.Create(xmlFS, settings); if (reader != null) { System.Text.StringBuilder sbXML = new System.Text.StringBuilder(); while (reader.Read()) { @sbXML.AppendLine(reader.ReadOuterXml()); } // Convert the xml string to a DynamicXml object dynamic xmlFeed = Library.ToDynamicXml(sbXML.ToString()); // Retrieve the items Umbraco.Core.Dynamics.DynamicXml items = xmlFeed.XPath("/xmlFeed/item");
An alternative I thought of would be to deserialize into a class and output using the object.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Read in XML file and transform to HTML with Razor
Hi
What is the best approach to read in and XML file and transform to HTML.
I want to use Razor and not XSLT
Thanks
This is how I managed to solve this.
FileStream xmlFS = new FileStream(Server.MapPath("/xml/timeline.xml"), FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read);
An alternative I thought of would be to deserialize into a class and output using the object.
is working on a reply...