Page 1 of 2

XML parsing [Archive] - ForumsHQ

Posted: Tue Oct 21, 2003 7:21 pm
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?

Re: XML parsing [Archive] - ForumsHQ

Posted: Tue Oct 21, 2003 10:47 pm
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?

Re: XML parsing [Archive] - ForumsHQ

Posted: Wed Oct 22, 2003 1:39 am
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

Re: XML parsing [Archive] - ForumsHQ

Posted: Wed Oct 22, 2003 8:04 am
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

Re: XML parsing [Archive] - ForumsHQ

Posted: Wed Oct 22, 2003 12:29 pm
by War Hawk
can apache even handle vbscript? I thought that was a microshaft thing

Re: XML parsing [Archive] - ForumsHQ

Posted: Wed Oct 22, 2003 12:47 pm
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

Re: XML parsing [Archive] - ForumsHQ

Posted: Wed Oct 22, 2003 12:49 pm
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

Re: XML parsing [Archive] - ForumsHQ

Posted: Wed Oct 22, 2003 3:05 pm
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

Re: XML parsing [Archive] - ForumsHQ

Posted: Wed Oct 22, 2003 6:28 pm
by Raybdbomb
works for me,



thx warhawk

Re: XML parsing [Archive] - ForumsHQ

Posted: Wed Oct 22, 2003 9:18 pm
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 :)