I am currently trying to figure out how I can add content to a web page, which has been transformed from an XML document into HTML by an XSLT document. The solution I have thought of looks like this...
Is there a better way?
public static LiteralControl XmlFileTransform(string xmlfile, string xslfile)
StringWriter writer = new StringWriter();
xml = new XPathDocument(new XmlTextReader(xmlfile));
xslt = new XslTransform();
xslt.Transform(xml, null, writer, null);
return new LiteralControl(writer.ToString());
In the above solution I turn the generated HTML into a LiteralControl and then return this. I am not sure if this is the best solution for adding the generated output to the page dynamically. What do you think?
Is it possible to make a transformation of part of a document?
Say I have selected only one node and I have made an XSLT document that matches this one node.