For Programmers: Free Programming Magazines  


Home > Archive > ASP > January 2007 > Help accessing an XML document from a URL









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help accessing an XML document from a URL
TheDude5B

2007-01-23, 6:57 pm

Hi, I have the following code which accesses an XML document and then
displays the document using XSL.
-----------------------------------------------------------------------------------------------------------------------
Dim xmlDocument
Dim xslDocument
Dim path
Dim XSLTemplate
Dim proc
Dim nodes

set xmlDocument=CreateObject("MSXML2.FreeThreadedDOMDocument")
xmlDocument.async="false"
xmlDocument.load(Server.MapPath("test.xml"))
path="/forum"
set nodes = xmlDocument.selectNodes(path)

If nodes.length = 0 Then

Response.Redirect("noMatch.asp")

Else

set xslDocument=CreateObject("MSXML2.FreeThreadedDOMDocument")
xslDocument.async="false"
xslDocument.load(Server.MapPath("gigs.xsl"))
Set XSLTemplate =Server.CreateObject("MSXML2.XSLTemplate")
Set XSLTemplate.stylesheet = xslDocument
Set proc=XSLTemplate.createProcessor()

proc.input = xmlDocument
proc.Transform

Response.Write proc.output

End If
------------------------------------------------------------------------------------------------------------------------------------

The code works fine when I am loading the XML document from the local
server, but when I change the code to:

xmlDocument.Load("http://myurl.com/db/test.xml")

I seem to have problems. The browser seems to get stuck loading and
never returns any value, not even an error message.

Is this the correct way to load an XML document from a URL? Is there
some sort of server setting which may be blocking my code from access
this XML document?

.............................

Another Question.
.............................

Once I have solved this problem, I have another problem. The XML
document is not formed in a familiar way that I am used to, so I am
unsure of how to display it via XSL. The XML document looks like this.

-------------------------------------------------------------------------------------------------------

<?xml version="1.0"?>
<clubnme>
<LONDON>
<venue>London KOKO</venue>
<address>1A Camden High Street, NW1</address>
<url>http://www.koko.uk.com</url>
<gig1>January 19th - The On/Offs</gig1>
<gig2>January 26th - The Envy Corps & Low Vs Diamond</gig2>
</LONDON>

<ABERDEEN>
<venue>Aberdeen Moshulu</venue>
<address>Windmill Brae, Aberdeen, AB11 6HU</address>
<url> </url>
<gig1>January 30th - Pop Levi</gig1>
<gig2>February 6th - Ratatat & the Whip</gig2>
</ABERDEEN>

<BIRMINGHAM>
<venue>Birmingham Custard Factory</venue>
<address>Gibb Square, Birmingham, B9 4AA</address>
<url> </url>
<gig1>January 25th - The Violets</gig1>
<gig2>February 1st - Ratatat</gig2>
</BIRMINGHAM>
</clubnme>

----------------------------------------------------------------------------------------------------------------

I want to be able to display each part as City, Venue, Address, URL,
and then the gigs. But because the City is not within a <city> tag and
is just displayed as <LONDON>, how would I access this data in XSL ?

Sorry for the long questiong, but I really need help with this now.

Thanks

Anthony Jones

2007-01-23, 6:57 pm


"TheDude5B" <timbjames@gmail.com> wrote in message
news:1169562991.103634.257870@d71g2000cwa.googlegroups.com...
> Hi, I have the following code which accesses an XML document and then
> displays the document using XSL.
> --------------------------------------------------------------------------

---------------------------------------------
> Dim xmlDocument
> Dim xslDocument
> Dim path
> Dim XSLTemplate
> Dim proc
> Dim nodes
>


<snip>

You've asked this question also in the XML group where it has been answered
please don't multipost. If you are unsure which group to post to use a
cross post.



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com