I have an XML document and an XSLT transformation sheet. My first issue is that my XML file won't load into the XPathDocument object. However, when I use an obsolete transformation method where I specify the XML input file and output file, I get the same error. The error is:
An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.
Here's my code... commented to show where the errors are...
//XmlDocument xmlDoc = new XmlDocument();
XslTransform xslDoc = new XslTransform();
// ++++++ IF I UNCOMMENT THIS, THE FILE LOADS JUST FINE
//xmlDoc.Load(this.xmlFilePath.Text);
//xmlDoc.Save(@"c:\temp\xml.xml");
xslDoc.Load(this.xslFilePath.Text, null);
// +++++ ERROR HAPPENS HERE...
XPathDocument xpathdocument = new XPathDocument(@"C:\Temp\xml.xml");
XmlTextWriter writer = new XmlTextWriter(@"C:\temp\output.html", System.Text.Encoding.UTF8);
writer.Formatting = Formatting.Indented;// never reaches this part
xslDoc.Transform(xpathdocument, null, writer, null);
// +++++ IF I CHANGE THIS TO THE FOLLWOING, I GET THE SAME ERROR:
xslDoc.Transform(@"c:\temp\xml.xml", @"c:\temp\output.html");
Dare Obasanjo [MSFT] - 27 Nov 2003 03:20 GMT
Why don't you catch the exception and print it out to see what the error is? It looks like there is an error in your file.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
I have an XML document and an XSLT transformation sheet. My first issue is that my XML file won't load into the XPathDocument object. However, when I use an obsolete transformation method where I specify the XML input file and output file, I get the same error. The error is:
An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.
Here's my code... commented to show where the errors are...
//XmlDocument xmlDoc = new XmlDocument();
XslTransform xslDoc = new XslTransform();
// ++++++ IF I UNCOMMENT THIS, THE FILE LOADS JUST FINE
//xmlDoc.Load(this.xmlFilePath.Text);
//xmlDoc.Save(@"c:\temp\xml.xml");
xslDoc.Load(this.xslFilePath.Text, null);
// +++++ ERROR HAPPENS HERE...
XPathDocument xpathdocument = new XPathDocument(@"C:\Temp\xml.xml");
XmlTextWriter writer = new XmlTextWriter(@"C:\temp\output.html", System.Text.Encoding.UTF8);
writer.Formatting = Formatting.Indented;// never reaches this part
xslDoc.Transform(xpathdocument, null, writer, null);
// +++++ IF I CHANGE THIS TO THE FOLLWOING, I GET THE SAME ERROR:
xslDoc.Transform(@"c:\temp\xml.xml", @"c:\temp\output.html");