O
otherblandart
Hi All and thanks in advance for any help I can get with this!
I'm very new at ASP/XML/HTML, but pretty comfortable with VB/
VBScript.
I've been tasked with some web content development tasks, and among
them is a 'catalog' style page of images. Rather than hard-coding all
the items, I wanted to use an XML file to store all the image paths
and descriptive text, and just loop thru it to generate the HTML I
need. Later on I'll be adding things like filters on category, etc.,
but for now I just want to get a simple protoype working. Below is
what I've come up with but it just isn't working (keep getting HTTP
500 Internal Server Error with IE 6).
The objects/methods worked pretty well in VB, so I'm wondering if
it's
in my handling of the quotation marks...
Thanks again for the help!
Hal
[XML File]
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<imgpath>images/success_do.jpg</imgpath>
<described>"Success Means Do.." Poster 24X16</described>
</item>
<item>
<imgpath>images/Think_Twice.jpg</imgpath>
<described>"Think Twice.. Act Once" Poster 18X36</described>
</item>
</items>
[ASP Page Text]
<html>
<%
dim strServer
dim objXML, xNodeList, xNode
dim i , s, sDesc, sPath
strServer = Request.ServerVariables("SERVER_NAME")
%>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta name="Author" content="Publishing, Desktop" />
<meta name="Contact" content="Publishing, Desktop" />
<title>Order Framed Art</title>
</head>
<body>
<%
set objXML = Server.CreateObject("Microsoft.XMLDOM")
sPath = "http://" & strServer & "/vendor_mgmt/docs/artlist.xml"
objXML.async = False
objXML.load(sPath)
If objXML.parseError.errorcode <> 0 then
Response.Write "Sorry, an error occurred retrieving information."
else
Set xNodeList =
objXML.documentElement.getElementsByTagName("item")
If xNodeList.length > 0 then
For i=0 to xNodeList.length-1
'[imgpath] element/field
sPath = "http://" & strServer & "/vendor_mgmt/" &
xNodelist.Item(i).childNodes(0).text
'[described] element/field
sDesc = xNodelist.Item(i).childNodes(1).text
s = "<a title=" & Chr(34) & sDesc & Chr(34) & " href=" &
Chr(34) & sPath & Chr(34)
s = s & & " target=" & Chr(34) & "_blank" & Chr(34) & ">"
Response.Write s
s = "<img border=" & Chr(34) & "0" & Chr(34) & " src=" &
Chr(34) & sPath & Chr(34) & " width=" & Chr(34) & "50" & Chr(34)
s = s & " height=" & Chr(34) & "50" & Chr(34) & " align="
& Chr(34) & "middle" & Chr(34) & "></a><br />"
Response.Write s
s = "<a href=" & Chr(34) & sPath & Chr(34) & " target=" &
Chr(34) & "_blank" & Chr(34) & ">" & i & ". "
s = s & sDesc & "</a>"
Response.Write s
next
else
'no items exist
end if
end if
%>
</body>
</html>
I'm very new at ASP/XML/HTML, but pretty comfortable with VB/
VBScript.
I've been tasked with some web content development tasks, and among
them is a 'catalog' style page of images. Rather than hard-coding all
the items, I wanted to use an XML file to store all the image paths
and descriptive text, and just loop thru it to generate the HTML I
need. Later on I'll be adding things like filters on category, etc.,
but for now I just want to get a simple protoype working. Below is
what I've come up with but it just isn't working (keep getting HTTP
500 Internal Server Error with IE 6).
The objects/methods worked pretty well in VB, so I'm wondering if
it's
in my handling of the quotation marks...
Thanks again for the help!
Hal
[XML File]
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<imgpath>images/success_do.jpg</imgpath>
<described>"Success Means Do.." Poster 24X16</described>
</item>
<item>
<imgpath>images/Think_Twice.jpg</imgpath>
<described>"Think Twice.. Act Once" Poster 18X36</described>
</item>
</items>
[ASP Page Text]
<html>
<%
dim strServer
dim objXML, xNodeList, xNode
dim i , s, sDesc, sPath
strServer = Request.ServerVariables("SERVER_NAME")
%>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta name="Author" content="Publishing, Desktop" />
<meta name="Contact" content="Publishing, Desktop" />
<title>Order Framed Art</title>
</head>
<body>
<%
set objXML = Server.CreateObject("Microsoft.XMLDOM")
sPath = "http://" & strServer & "/vendor_mgmt/docs/artlist.xml"
objXML.async = False
objXML.load(sPath)
If objXML.parseError.errorcode <> 0 then
Response.Write "Sorry, an error occurred retrieving information."
else
Set xNodeList =
objXML.documentElement.getElementsByTagName("item")
If xNodeList.length > 0 then
For i=0 to xNodeList.length-1
'[imgpath] element/field
sPath = "http://" & strServer & "/vendor_mgmt/" &
xNodelist.Item(i).childNodes(0).text
'[described] element/field
sDesc = xNodelist.Item(i).childNodes(1).text
s = "<a title=" & Chr(34) & sDesc & Chr(34) & " href=" &
Chr(34) & sPath & Chr(34)
s = s & & " target=" & Chr(34) & "_blank" & Chr(34) & ">"
Response.Write s
s = "<img border=" & Chr(34) & "0" & Chr(34) & " src=" &
Chr(34) & sPath & Chr(34) & " width=" & Chr(34) & "50" & Chr(34)
s = s & " height=" & Chr(34) & "50" & Chr(34) & " align="
& Chr(34) & "middle" & Chr(34) & "></a><br />"
Response.Write s
s = "<a href=" & Chr(34) & sPath & Chr(34) & " target=" &
Chr(34) & "_blank" & Chr(34) & ">" & i & ". "
s = s & sDesc & "</a>"
Response.Write s
next
else
'no items exist
end if
end if
%>
</body>
</html>