Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading XML files

Status
Not open for further replies.

Pyramus

Programmer
Dec 19, 2001
237
GB
Is it possible for an ASP page to read XML files located on the CLIENT'S system (not server-side) if we know the location of the XML files?

Thanks
 
My initial reaction is that you would have to create your own ActiveX control (pluggin) for doing that, and place it on your ASP page. The control would then be downloaded and run on the client, giving you access to the clients entire machine.

Now, there are security implications associated with this approach, and the control must be implement certain "safe for scripting" type COM interfaces.

Such a control could be written in VB 6.0, as an OCX.

Regards,
TJRTech.
 
XML has a built in HTTPRequest to access XML document anywhere here is some code that will get an XML document and display the contents.
<%option explicit%>
<%
on error resume next
' Set the source and stylesheet locations here
dim sourceCategory
dim sourceFile
dim styleFile
dim source
dim style
dim result

sourceCategory = Request.QueryString(&quot;c&quot;)
If sourceCategory = &quot;&quot; Then
sourceCategory = &quot;Videogame news&quot;
End If

sourceFile = &quot; & sourceCategory & &quot;&o=xml&quot;
styleFile = &quot;

' Load the XML
Set source = Server.CreateObject(&quot;Msxml2.DOMDocument.3.0&quot;)
source.async = false
source.setProperty &quot;ServerHTTPRequest&quot;, true
source.load sourceFile

' Load the XSL
Set style = Server.CreateObject(&quot;Msxml2.DOMDocument.3.0&quot;)
style.async = false
style.setProperty &quot;ServerHTTPRequest&quot;, true
style.load styleFile

'Check for errors - Display errors or perform the transformation and output the results.
If source.parseError.errorCode Then
result = &quot;source error: &quot; & source.parseError & &quot; --&quot;
Else
If style.parseError.errorCode Then
result = &quot;style error &quot; & style.parseError & &quot;//-->&quot;
Else
result = source.transformNode(style)
End If
End If

Response.Write result
if isObject(source) then set source = nothing
if isObject(style) then set style = nothing
if err.number <> 0 then
response.write err.Description
end if
%>
you should be able to cut and paste this code and run it,
but you can replace &quot;sourceFile&quot; and &quot;styleFile&quot; with your own, for personal testing. Megalene
If you crap it will stink!
 
Megalene, will what you propose work client-side, for XML docs stored on the client workstation? Or, is it really just a server-side, ASP solution that can read XML files from any-old HTTP location (URL)?

TJRTech
 
Is this for an intranet? If so you could use your network path instead of the http path of the XML document. After testing here at work locally I was able to view xml documents hosted on another workstation. Megalene
If you crap it will stink!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top