XML + ASP

R

Robert J Egan

Hi i'm trying to search a remote website page. The form returns xml
information, though the page extension is missing. I retrieve the
information and write it to the screen. So far so good - However i cannot
format this information in anyway. A copy of the returned information saved
to my server results in the xml data being formatted and displayed as
intended! Can anyone explain to me why one would work but not the other.

Regards

Robert Egan

-- Code Below --

str_HC_url - variable formed from form information

xml.Open "GET", str_HC_url , false - line of code used - does not work

The above brings back info but cannot be formatted using code below.

Set xml = Server.CreateObject ("Microsoft.XMLHTTP")
xml.Open "GET", "http://www.accessburnley.co.uk/xml/asp/cdcatalog.xml" ,
false - alternate line of code - does work.
xml.Send
text = xml.ResponseText

If xml.Status = 200 Then
Set oResponseXML = xml.ResponseXML
bXMLLoadError = False
Else
Response.Write("<font color=""red"">Page Error: Could not load XML from
remote server</font><br>")
bXMLLoadError = True
End If

Set xml = nothing

If Not bXMLLoadError Then

// Load XML
set oXML = Server.CreateObject("Microsoft.XMLDOM")
oXML.Async = false
oXML.Load(oResponseXML)

// Load XSL
set oXSL = Server.CreateObject("Microsoft.XMLDOM")
oXSL.Async = False
'oXSL.Load(Server.MapPath("HotCourses.xsl"))
oXSL.Load(Server.MapPath("cdcatalog_ex3.xsl"))
// Transform
'Response.Write(oXML.transformNode(oXSL))

End If
 
M

Mark Schupp

Response.ContentType = "text/xml"
Response.Write <xml string here>
Response.End
 
R

Robert J Egan

Not sure where this should go as the output works fine when using a xml file
saved to my server, but when hitting the same result on a remote it doesn't.
The output is handled by a '.xsl' file, which outputs HTML as follows....

<html>
<body>
<h2>Courses</h2>
<table border="1">
<tr>
<td colspan="9">Search Phrase</td>
</tr>
<tr>
<td colspan="9">Records Returned</td>
</tr>
<tr bgcolor="#9acd32">
<th>CourseId</th>
<th>LDCS</th>
<th>Name</th>
<th>QualificationType</th>
<th>Description</th>
<th>LearnDirectFlag</th>
<th>Venue</th>
<th>AttendanceType</th>
<th>StartDetails</th>
</tr>
<tr>
<td>4988812</td>
<td>AK.6,FN.343</td>
<td>Accounting with French BA (Hons)</td>
<td>First Degree</td>
<td>3 year full time/ up to 8 years part time course run by Middlesex
University</td>
<td>TC</td>
<td>Hendon Campus</td>
<td>Full Time</td>
<td>Sep/04</td>
</tr>
<tr>
<td>4081296</td>
<td>AK.6,FN.343</td>
<td>Accounting with French BA (Hons)</td>
<td>First Degree</td>
<td>3 year full time/ up to 8 years part time course run by Middlesex
University</td>
<td>TC</td>
<td>Middlesex University</td>
<td>Full Time</td>
<td>Sep/04</td>
</tr>
.................. etc

</table>
</body>
</html>

-------------
 
M

Mark Schupp

sorry, missed the part about XSL.

First, make sure that you are getting a valid XML response.
response.contenttype = "text/xml"
response.write text
response.end

Next make sure that xml.ResponseXML is returning a valid xml document.
According to the MS documentation, if the originator
(http://www.accessburnley.co.uk/xml/asp/cdcatalog.xml) does not set the
response type to "text/xml" then you will get an empty document from
ResponseXML.

If the above is the case use oXML.LoadXML(xml.ResponseText) instead of using
oXML.Load (note: you can load the document directly into the DomDocument
object with the Load method by giving it the URL to the XML file).

Once you are sure that the DomDocument object is loaded ( response.write
oXML.xml) then you can start working on the XSL transformation (if it is not
already known to work properly).
 
R

Robert J Egan

Mark,

Many thanks for your help

You've helped my understanding of this new subject for me. The search now
works using the remote page. I hadn't followed the specification 100%. There
was a space in the postcode! - Doh

My Search - http://www.accessburnley.co.uk/xml/asp/hotcourses.asp
The Remote Server -
http://213.219.10.130/pls/cgi-bin-c... 1UF&distance=50&LDCS=&Level=&LearningType=17,
18&GetXRecords=5000&PhraseSearch=French

In my xsl file that transforms the results i loop through the records but
cannot not retrieve the number of results found or the search phrase used -
why?. Also do you see me being able to page through these results? If so any
ideas how?

Regards

Rob

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Courses</h2>
<table border="1">
<tr>
<td colspan="9">Search Phrase<xsl:value-of select="PhraseSearch" /></td>
</tr>
<tr>
<td colspan="9">Records Returned<xsl:value-of select="RecordsReturned"
/></td>
</tr>
<tr bgcolor="#9acd32">
<th>CourseId</th>
<th>LDCS</th>
<th>Name</th>
<th>QualificationType</th>
<th>Description</th>
<th>LearnDirectFlag</th>
<th>Venue</th>
<th>AttendanceType</th>
<th>StartDetails</th>
</tr>
<xsl:for-each select="learndirect-list/Record">
<xsl:sort select="Name"/>
<tr>
<td><xsl:value-of select="CourseId" /></td>
<td><xsl:value-of select="LDCS" /></td>
<td><xsl:value-of select="Name" /></td>
<td><xsl:value-of select="QualificationType" /></td>
<td><xsl:value-of select="Description" /></td>
<td><xsl:value-of select="LearnDirectFlag" /></td>
<td><xsl:value-of select="Venue" /></td>
<td><xsl:value-of select="AttendanceType" /></td>
<td><xsl:value-of select="StartDetails" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
 
R

Robert J Egan

Mark have managed to get the search phrase, and number of records back -
just didn't know the syntax! If you can shed some light on the paging of the
results then that would be great! Not sure where to do it or how.

rob
 
M

Mark Schupp

Paging would best be done in the query itself. If it does not support paging
(look through www.aspfaq.com for examples of some common techniques) and you
are including all results in the XML file then you might consider using
JavaScript on the client to display one page of results at a time. Put the
results in a JavaScript array and redraw the table with the current page's
data.
 
R

Robert J Egan

Thanks for your advise Mark. I'm looking in to using the JavaScript approach
you mentioned.

Cheers

Rob :)
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top