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!

XML newbie question - spot the difference

Status
Not open for further replies.

shedlord2

Technical User
May 20, 2006
36
GB
I'm an XML newbie trying to add a property search and a featured property to an estate agent's website using various XML bits sent to me by the people who host their properties (a company called Dezrez).

Click here to see what the XML looks like for the property search results...

...and here to see it for the featured properties results...

Is this latter XML formed properly? The first one is recognized as XML by the browser but the second seems to be interpreted as a web page (which might be why I am getting 0 results when running this through XSL or XSLT files??)

thanks
 
I noticed the text which displays in the browser for the second link is the content of the three <ea_tel> values put together.
Each of those is formatted like this...

<ea_tel>023 92 602155</ea_tel>

Also noticed if I save and upload the content of the second link as .xml it displays ok as an xml file in the browser.
 
It was pointed out to me that I need to set Response.ContentType = "application/xml" or Response.ContentType = "text/xml" in my ASP to get this returned as XML.

I'm still struggling to get this working though.

Using the results from...
(slightly corrupted in my original message).

**** Test 1: Files are features2.asp & test.xsl ****

---test.xsl---

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="
<xsl:template match="/">
<html>
<body>
<h2>TEST</h2>
<table border="1">
<xsl:for-each select="properties/property">
<tr>
<td><xsl:value-of select="price" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>



--featured2.asp---

<%
Response.ContentType = "text/xml"

dim sLink
dim xslt
dim oHttpRequest
dim outputHTML

sLink = "
'response.write(sLink)
'xml request objects
'Load XML

Set XML = Server.CreateObject("Microsoft.XMLDOM")
set xmlhttp=createObject("Microsoft.XMLHTTP")
xmlhttp.onreadystatechange=getRef("stateChange")
xmlhttp.Open "POST", sLink, false
xmlhttp.Send()

'dim blah
'blah = xmlhttp.responseText

'XML received
function stateChange()


dim num
if xmlhttp.readyState=4 then
if xmlhttp.status=200 then
xml.load (xmlhttp.responseXML)

'load XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath("test.xsl"))

'Transform file
outputHTML = xml.transformNode(xsl)
else
Response.Write("XML data not OK")
Response.Write(xmlhttp.responseXML)
end if
end if


end function
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<%
Response.write(outputHTML)
'Response.write(blah)
%>
</body>
</html>


Result = just the heading TEST


What am I doing wrong here?
 
Link corrupted again. Should end &showxml=1 (no semi-colon)
 
My other test, using an XSLT file currently looks like this...

Files - featured.asp & searchresults4.xslt

---- searchresults4.xslt ----

<?xml version="1.0" encoding="windows-1252" ?>
<xsl:stylesheet xmlns:xsl="version="1.0">
<xsl:eek:utput method="html"/>
<xsl:template match="/">
<xsl:value-of select select="count(properties/property)"/>
</xsl:template>
</xsl:stylesheet>

The idea is that as a basic test we just count the number of property
nodes.

---- featured.asp ----

Exactly as posted previously but pointed at the xslt file above...

xsl.load(Server.MapPath("searchresults4.xslt"))

---- Result: "The stylesheet does not contain a document element. The
stylesheet may be empty, or it may not be a well-formed XML document."
 
><td><xsl:value-of select="price" /></td>
[tt]<td><xsl:value-of select="[red]@[/red]price" /></td>[/tt]
 
I've taken a look at your various posts. What is finally you end up with? what is not working?
 
Well, I had it pointed out that this line is wrong

<xsl:value-of select select="count(properties/property)"/>

...too many selects in there. This solved the "The stylesheet does not contain a document element" error. I still wasn't receiving the correct, expected result though.

In the end, one of the developers from the company providing the XML feed sent me something completely different, which works. So I never did find out what was wrong with my simple effort above!
 
Since you've solved the problem, I consider case closed. I can only add a note that the page served at the url quoted is properly made and is not the source of the problem and that "too many selects" is just typo-kind of problem and is not the generic source of the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top