Hi everyone. I am having a hard time getting Brians code to work with
my server. I have figured out where the code is failing but I am not
sure why and I am not sure how to correct the error.
Here is the dump from the debugger.
------ Running ------
HTTP result:
str: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Index of /media</title>
</head>
<body>
<h1>Index of /media</h1>
<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th><a
href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></
th><th><a href="?C=S;O=A">Size</a></th><th><a href="?
C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr>
<tr><td valign="top"><img src="/icons/back.gif" alt="[DIR]"></
td><td><a href="/">Parent Directory</a></td><td> </td><td
align="right"> - </td><td> </td></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></
td><td><a href="episodes/">episodes/</a></td><td align="right">06-
Aug-2011 16:48 </td><td align="right"> - </td><td> </td></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></
td><td><a href="movies/">movies/</a></td><td align="right">06-Aug-2011
10:30 </td><td align="right"> - </td><td> </td></tr>
<tr><th colspan="5"><hr></th></tr>
</table>
<address>Apache/2.2.17 (Fedora) Server at 192.168.0.14 Port 80</
address>
</body></html>
response: 0
reason:
error: false
Server set to
192.168.0.14/media
HTTP result:
str: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Index of /media</title>
</head>
<body>
<h1>Index of /media</h1>
<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th><a
href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></
th><th><a href="?C=S;O=A">Size</a></th><th><a href="?
C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr>
<tr><td valign="top"><img src="/icons/back.gif" alt="[DIR]"></
td><td><a href="/">Parent Directory</a></td><td> </td><td
align="right"> - </td><td> </td></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></
td><td><a href="episodes/">episodes/</a></td><td align="right">06-
Aug-2011 16:48 </td><td align="right"> - </td><td> </td></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></
td><td><a href="movies/">movies/</a></td><td align="right">06-Aug-2011
10:30 </td><td align="right"> - </td><td> </td></tr>
<tr><th colspan="5"><hr></th></tr>
</table>
<address>Apache/2.2.17 (Fedora) Server at 192.168.0.14 Port 80</
address>
</body></html>
response: 0
reason:
error: false
Cannot parse directory listing as XML
Here is the code that is failing.
Function getDirectoryListing(url As String) As Object
result = getHTMLWithTimeout(url, 60)
if result.error then
print "ERROR: Could not get directory listing"
return invalid
end if
dir = result.str
' Try parsing the html as if it is XML
xml=CreateObject("roXMLElement")
if not xml.Parse(dir) then
print "Cannot parse directory listing as XML"
return invalid
end if
' grab all the <a href /> elements
urls = getUrls({}, xml)
return urls
End Function
Function getUrls(array as Object, element as Object) As Object
if element.GetName() = "a" and element.HasAttribute("href") then
array.AddReplace(element.GetAttributes()["href"], "")
end if
if element.GetChildElements()<>invalid then
for each e in element.GetChildElements()
getUrls(array, e)
end for
end if
return array
End Function
its failing when it trys xml.parse(dir) but as I mentioned I am not
sure how to correct that situation. I am thinking maybe it is
something on my server but I am honestly not sure.
Any help would be greatly appreciated. Thank you.