I’m having an issue where I try to pull the filePath of an XML file using the XML web control. The XML file is stored in a different directory and I am using an ashx file to serve it up. The ashx file works by appending the XML file name to the end of the string.
Dim oXML As New System.Web.UI.WebControls.Xml
oXML.DocumentSource = Server.MapPath("xmlHandler.ashx") & "?xml=sampleXMLfile.xml"
oXML.TransformSource = Server.MapPath("xmlStyles.xslt")
oXML.DataBind()
This doesn’t seem to be working for me, and I was wondering if pulling the XML into the code behind is the only way?
Thanks for your help!
MapPathmaps a HTTP path/virtual path to a physical folder: http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath.aspxSo the result,
c:\file\on\disk\etc\xmlHandler.ashx?xml=sampleXMLfile.xml, doesn’t make sense: it’s not a local filename.If you want to download that URL, take a look at the
WebClientclass: http://msdn.microsoft.com/en-us/library/system.net.webclient(v=vs.80).aspx…then set
DocumentSourceto anXmlDocumentloaded from the resulting downloaded data, or a string, or a local file path, as per http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.xml.documentsource(v=vs.80).aspx (As you can see, you can’t setDocumentSourceto a URL – not that you’re providing a valid URL anyway!)