"Invalid Xml" with XmlTransform

  • Thread starter Thread starter GS
  • Start date Start date
G

GS

Hi!

I am getting an "Invalid Xml" exception when I try to load an xsl file
using XslTransform.Load(string url). The Xsl file is valid and works
fine if I just rename the file.

There are some postings with this problem, but none of them have a
solution as yet. If anyone has any ideas on how to resolve this, please
do post.

Thank you.
 
GS said:
Hi!

I am getting an "Invalid Xml" exception when I try to load an xsl file
using XslTransform.Load(string url). The Xsl file is valid and works
fine if I just rename the file.

There are some postings with this problem, but none of them have a
solution as yet. If anyone has any ideas on how to resolve this, please
do post.

Thank you.

http://msdn.microsoft.com/library/d...rfsystemxmlxslxsltransformclassloadtopic2.asp
Is this what you're doing?

using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;

public class Sample
{
private const String filename = "books.xml";
private const String stylesheet = "output.xsl";

public static void Main()
{
//Load the stylesheet.
XslTransform xslt = new XslTransform();
xslt.Load(stylesheet);

//Load the file to transform.
XPathDocument doc = new XPathDocument(filename);

//Create an XmlTextWriter which outputs to the console.
XmlTextWriter writer = new XmlTextWriter(Console.Out);

//Transform the file and send the output to the console.
xslt.Transform(doc, null, writer, null);
writer.Close();

}
}
 
Yes, but it fails at ---

xslt.Load(stylesheet);

Also the xml and the xsl files are not as simple as in the example.
 
I've seen this happen where you may need to use special entity
characters to replace ampersands and other characters.

SO

<myxml>This & that</myxml>

becomes

<myxml>This &amp; that</myxml>
 
Back
Top