i created the following code for my classic asp page that i want to port to asp.net:
Set MasterXML = Server.CreateObject("Microsoft.XMLDOM")
MasterXML.async = False
MasterXML.Load(xmlFile)
Set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = False
xsl.validateOnParse="false"
xsl.load(xslFile)
Response.Write (MasterXML.transformNode(xsl))
how would i realize this in asp.net2.0 using C#

Code conversion: asp VB ->asp.net 2.0 C#
Tahaner
good question, and that did solve the problem!
thanks!
theumpteenthbrian
(in a seperate file: )
public abstract class XMLWorker
{
protected XmlDocument xmlDoc = new XmlDocument();
protected XMLWorker()
{
}
}
/// <summary>
/// The Root XML Document container in wich the XML stream is compiled.
/// </summary>
public sealed class XMLPageCore : XMLWorker
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="Path2BaseXML">Path to the BaseXML File.</param>
public XMLPageCore(string Path2BaseXML)
{
xmlDoc.Load(Path2BaseXML);
}
/// <summary>
/// Will deploy the XMLdocument to the Passed Stream
/// </summary>
/// <param name="XSLTPath">Path to the XSLT file</param>
/// <param name="Stream">Will contain the XSLT results</param>
public void Deploy(string XSLTPath,System.IO.Stream Stream)
{
System.Xml.Xsl.XslCompiledTransform XSLT = new System.Xml.Xsl.XslCompiledTransform();
XSLT.Load(XSLTPath);
XSLT.Transform(xmlDoc.DocumentElement,null,Stream);
}
}
(then on the page)
XMLPageCore test = new XMLPageCore(Server.MapPath("/test/XMLFile.xml"));
test.Deploy(Server.MapPath("/test/XSLTFile.xsl"),Response.OutputStream);
the transform works when i use the 1st overload (it takes the input file and an outputfile location) and that works perfectly, but when i try to get the output/results directly into the response stream, all i get are the XML processing instructions (< ... ) and then the content of the xml file, but without any whitespace, or xml/transformed html tags. just the contents without any whitespace and the PI infront.
saMug
something like
using System.Xml.Xsl;
using System.Xml.XPath;
XPathDocument xmlDoc = new XPathDocument(Server.MapPath("yourxml.xml"));
XslTransform xslt = new XslTransform();
xslt.Load(Server.MapPath("yourxsl.xsl"));
Response.ContentType = "text/html";
xslt.Transform(xmlDoc, null, Response.OutputStream,null);
also see
http://support.microsoft.com/default.aspx scid=kb;en-us;323370
M3NTA7
why xmlDoc.DocumentElement not xmlDoc
try it locally, add the following to XMLFile.xml
< xml-stylesheet type="text/xsl" href="XSLTFile.xsl" >
the use a browser to open the xml file
XMLPageCore test = new XMLPageCore(Server.MapPath("/test/XMLFile.xml"));
or write the output to a string to verify if the xslt is correct
StringBuilder sb = new StringBuilder();
StringWriter writer = new StringWriter(sb);
test.Deploy(Server.MapPath("/test/XSLTFile.xsl"),writer);
writer.Close();
Response.Write("****" + sb.ToString() + "****");