Loading external files (xsl and xml)

B

bissatch

Hi,

I have two files, a XML and a XSL, sitting on a LAMP server. The XSL
file is dynamically created using PHP and MySQL so it must stay there.
However, I want to load the files into a ASP .NET application.

My ASP .NET app is as follows:

<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<%@ Import Namespace="System.Xml.XPath" %>
<script language="C#" runat="server">

public void Page_Load(Object sender, EventArgs E)
{
string xmlPath = Server.MapPath("http://www.mydomain.net/xml/
home.xml");
string xslPath = Server.MapPath("http://www.mydomain.net/xml/
home_xsl.php");

//Instantiate the XPathDocument Class
XPathDocument doc = new XPathDocument(xmlPath);

//Instantiate the XslTransform Class
XslTransform transform = new XslTransform();
transform.Load(xslPath);

//Custom format the indenting of the output document
//by using an XmlTextWriter
XmlTextWriter writer = new XmlTextWriter(Response.Output);
writer.Formatting = Formatting.Indented;
writer.Indentation=4;
transform.Transform(doc, null, writer);
}

</script>


Now, Im using Map.Path in the above example because it is was what I
was using when I had files that were relative to the aspx file, this
previously worked. I understand that this is not the correct method
here but I dont know how else to go about this. Can anyone please tell
me what the correct code for this would be? Thanks

Burnsy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top