I'd like to do the following and can't find an elegant way:
System.Xml.XmlDocument
XSLT
I've written CSS
Stylesheet WebBrowser
control I'm currently reading it from a file on disk, populating it, then saving it back out to disk after populating it. I reference the XSLT
in the template, and the CSS
in the XSLT
and then use the WebBrowser.Navigate([filename])
method to display the XML file.
Obviously, when I come to deploy this app, it'll break horribly as the file won't exist on disk, and I won't be able to reference the XSLT
and CSS
files in the XML
file as they'll be resources. I'm planning to include the template as a resource, but can't find a neat way to proceed from there.
Any help much appreciated
Quick question. Why do you need an Xml template? If you already know the schema before hand, then simply generate the complete Xml in your code. There shouldn't be a need for loading a template file.
Thanks for the link Keith, I'll have a look at that out of interest, as LINQ is on my list of things to learn. Unfortunately, I need to target .Net 2.0 for this app, so I think (please correct me if I'm wrong!) that LINQ is out of the question.
I've now included the CSS in the header of the XSLT, and I've found a way to use a System.Xml.Xsl.XslCompiledTransform object to transform the XML in memory. I'm currently using the WebBrowser.DocumentText property to pass the formatted XML into the WebBrowser componenet and this seems to work.
I can't help thinking that this isn't the best way of doing things, so any comments on better ways would be appreciated. In particular, if I were using LINQ, would I need a schema to bind to, and also, should I have a schema full-stop? I'm not great with XML, but I like Vaibhav's idea of generating straight from a schema rather than using a template. I'm just not sure where to start, so any pointers appreciated!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With