XML parsing [Archive] - ForumsHQ

Raybdbomb
Posts: 0
Joined: Wed Mar 21, 2001 6:00 am

XML parsing [Archive] - ForumsHQ

Post by Raybdbomb »

I want to be able to parse this file to show as html on my personal webpage.



http://www.slickdeals.net/rss.php



I talked with slickdeal's admin about it, and he said to use the following code:





set xmlDoc=CreateObject("Microsoft.XMLDOM")

xmlDoc.async="false"

xmlDoc.load("http://www.slickdeals.net/rss.php")

set title=xmlDoc.getElementsByTagName("title")

set link=xmlDoc.getElementsByTagName("link")





i=1;

while(link.item(i))

{

document.write('');

document.write(title.item(i).text);

document.write('');

i++;

}





However, when I try that code, I get an error, saying "Error: Access is denied." on line 4 which is loading the php file. anyway around this? any thoughts?
apathy
Posts: 0
Joined: Thu Aug 29, 2002 5:00 am

Re: XML parsing [Archive] - ForumsHQ

Post by apathy »

Note, I added just a "" so it would format a bit nicer.



Sorry this is a large file, but I'm lazy.



Edit: Point being, it works for me, so it's not the code. If you're doing this in Firebird, try it in IE. It doesn't work in Mozilla for me. Does anyone know if vbScript is M$ only?
Raybdbomb
Posts: 0
Joined: Wed Mar 21, 2001 6:00 am

Re: XML parsing [Archive] - ForumsHQ

Post by Raybdbomb »

no, see it works for me locally too, but when I try to put it on my server, that's when it has a problem
syntax53
Posts: 0
Joined: Wed Apr 03, 2002 6:00 am

Re: XML parsing [Archive] - ForumsHQ

Post by syntax53 »

no, see it works for me locally too, but when I try to put it on my server, that's when it has a problem



well i dont know shit about xml, but i know a lot about troubleshooting. and i can tell from the above posts that the problem is not in the code. judging by the error message you receive it sounds like a permissions problem on one of your server's directories/files. it looks like it writes to a .text file within the same directory as the script. does that directory have write permissions to the apache/public/anonymous groups (aka 777 for the permissions and assuming you're using an apache/linux server)? if it's in a directory that you don't want to allow those kind of permissions then modify the script to put the file in a writable directory.



my 2c anyway
War Hawk
Posts: 0
Joined: Thu Mar 07, 2002 6:00 am

Re: XML parsing [Archive] - ForumsHQ

Post by War Hawk »

can apache even handle vbscript? I thought that was a microshaft thing
Raybdbomb
Posts: 0
Joined: Wed Mar 21, 2001 6:00 am

Re: XML parsing [Archive] - ForumsHQ

Post by Raybdbomb »

well i dont know shit about xml, but i know a lot about troubleshooting. and i can tell from the above posts that the problem is not in the code. judging by the error message you receive it sounds like a permissions problem on one of your server's directories/files. it looks like it writes to a .text file within the same directory as the script. does that directory have write permissions to the apache/public/anonymous groups (aka 777 for the permissions and assuming you're using an apache/linux server)? if it's in a directory that you don't want to allow those kind of permissions then modify the script to put the file in a writable directory.



my 2c anyway



i'll try it but i think document.write is just the javascript way of outputting to the screen, like echo
Raybdbomb
Posts: 0
Joined: Wed Mar 21, 2001 6:00 am

Re: XML parsing [Archive] - ForumsHQ

Post by Raybdbomb »

i'll try it but i think document.write is just the javascript way of outputting to the screen, like echo



i chmod'd both the file and the directory to 777, didn't fix the problem
War Hawk
Posts: 0
Joined: Thu Mar 07, 2002 6:00 am

Re: XML parsing [Archive] - ForumsHQ

Post by War Hawk »

ray.php

















insideitem) {

$this->tag = $tagName;

} elseif ($tagName == "ITEM") {

$this->insideitem = true;

}

}



function endElement($parser, $tagName) {

if ($tagName == "ITEM") {

printf("%s",

trim($this->link),htmlspecialchars(trim($this->title)));

printf("%s",

htmlspecialchars(trim($this->description)));

$this->title = "";

$this->description = "";

$this->link = "";

$this->insideitem = false;

}

}



function characterData($parser, $data) {

if ($this->insideitem) {

switch ($this->tag) {

case "TITLE":

$this->title .= $data;

break;

case "DESCRIPTION":

$this->description .= $data;

break;

case "LINK":

$this->link .= $data;

break;

}

}

}

}



$xml_parser = xml_parser_create();

$rss_parser = new RSSParser();

xml_set_object($xml_parser,&$rss_parser);

xml_set_element_handler($xml_parser, "startElement", "endElement");

xml_set_character_data_handler($xml_parser, "characterData");

$fp = fopen("http://www.slickdeals.net/rss.php","r")

or die("Error reading RSS data.");

while ($data = fread($fp, 4096))

xml_parse($xml_parser, $data, feof($fp))

or die(sprintf("XML error: %s at line %d",

xml_error_string(xml_get_error_code($xml_parser)),

xml_get_current_line_number($xml_parser)));

fclose($fp);

xml_parser_free($xml_parser);







?>













taken from: http://www.sitepoint.com/article/560/4



it works.... http://mudview.mudinfo.net/test/ray.php
Raybdbomb
Posts: 0
Joined: Wed Mar 21, 2001 6:00 am

Re: XML parsing [Archive] - ForumsHQ

Post by Raybdbomb »

works for me,



thx warhawk
apathy
Posts: 0
Joined: Thu Aug 29, 2002 5:00 am

Re: XML parsing [Archive] - ForumsHQ

Post by apathy »

Yeah, I don't know why it didn't work, but I'm willing to chalk it up to trying to run vbScript on a linux box. And btw, when you get error codes in IE, don't believe the line numbers - they're horribly horribly wrong most of the time. Since JavaScript treats white space extremely oddly, the line counting is off



And WarHawk, decent code - I'mma jack that, too :)
Post Reply

Return to “Programming, web design & Graphics”