Nevermind, found the problem:
echo "<li><a style='font-family: Arial;font-size: .75em' href='[color=blue]
> {$_item['LINK']}' title='{$_item['TITLE']}'>" .
> "{$_item['TITLE']}</a></li>\n";[/color]
The single apostrophe after the href was actually not an apostrophe, I could
see the difference in dreamweaver. It must be a character issue when I
copied the code.
thanks for any help.
"Martman" <martman100@nospam.insightbb.com> wrote in message
news:1d0dc.217275$po.1072737@attbi_s52...[color=blue]
> I did not find urlencode via Dreamweaver search function, so here is the
> actual php page that is parsing the pcworld xml file:
> --------------------------------------------------------------------------[/color]
--[color=blue]
> ----
> <?
>
> $_item = array();
> $_depth = array();
> $_tags = array("dummy");
> /* "dummy" prevents unecessary subtraction
> * in the $_depth indexes */
>
>
> function initArray()
> {
> global $_item;
>
> $_item = array ("TITLE"=>"", "LINK"=>"",
> "DESCRIPTION"=>"", "URL"=>"");
> }
>
> function startElement($parser, $name)
>
> {
> global $_depth, $_tags, $_item;
>
> if (($name=="ITEM") || ($name=="CHANNEL")
> || ($name=="IMAGE")) {
> initArray();
> }
> $_depth[$parser]++;
> array_push($_tags, $name);
> }
>
> function endElement($parser, $name)
>
> {
> global $_depth, $_tags, $_item;
>
> array_pop($_tags);
> $_depth[$parser]--;
> switch ($name) {
> case "ITEM":
> echo "<li><a style='font-family: Arial;font-size: .75em'[/color]
href='[color=blue]
> {$_item['LINK']}' title='{$_item['TITLE']}'>" .
> "{$_item['TITLE']}</a></li>\n";
> initArray();
> break;
>
> case "IMAGE":
> echo "<a href='{$_item['LINK']}'>" .
> "<DEFANGED_IMG src='{$_item['URL']}' " .
> "alt='{$_item['TITLE']}; border='0'></a>\n<br />\n";
> initArray();
> break;
>
> case "CHANNEL":
> echo "<h4>{$_item['TITLE']}</h4>\n";
> initArray();
> break;
> }
> }
>
> function parseData($parser, $text)
> {
> global $_depth, $_tags, $_item;
>
> $crap = preg_replace ("/\s/", "", $text);
> /* is the data just whitespace?
> if so, we don't want it! */
>
> if ($crap) {
> $text = preg_replace ("/^\s+/", "", $text);
> /* get rid of leading whitespace */
> if ($_item[$_tags[$_depth[$parser]]]) {
> $_item[$_tags[$_depth[$parser]]] .= $text;
> } else {
> $_item[$_tags[$_depth[$parser]]] = $text;
> }
> }
> }
> function parseRDF($file)
> {
> global $_depth, $_tags, $_item;
>
> $xml_parser = xml_parser_create();
> initArray();
>
> /* Set up event handlers */
> xml_set_element_handler($xml_parser, "startElement", "endElement");
> xml_set_character_data_handler($xml_parser, "parseData");
>
> /* Open up the file */
> $fp = fopen ($file, "r") or die ("Could not open $file for input");
>
> while ($data = fread ($fp, 4096)) {
> if (!xml_parse($xml_parser, $data, feof($fp))) {
> 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);
> }
> ?>
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
>
> <body>
> <?php
> parseRDF("http://rss.pcworld.com/rss/pg_feed.rss?pgid=30");
> ?>
> </body>
> </html>
> --------------------------------------------------------------------------[/color]
--[color=blue]
> --------
>
> You can view the xml rss feed by visiting the link above.
>
> Thanks for any help this has me confused as to why it would be adding the
> current path to the link.
>
> Marty
>
>
>
> "Savut" <webki@hotmail.com> wrote in message
> news:VpUcc.2372$vf4.4829@news20.bellglobal.com...[color=green]
> > I guess it's because your application use a urlencode() somewhere.
> >
> > Exemple 1:
> > $encodedLink = urlencode("http://www.rssfeed.com/articleX.php");
> > echo ("http://www.mydomain.com/go.php?site=$encodedLink");
> > // and go.php do the redirect, this will work
> >
> > Exemple 2:
> > echo ("<a href='http://www.rssfeed.com/articleX.php'>Link</a>");
> > // this will work
> >
> > Exemple 3:
> > $encodedLink = urlencode("http://www.rssfeed.com");
> > echo ("<a href='$encodedLink'>Link</a>");
> > // this wont work
> >
> > This will result something like
> >
http://www.mydomain.com/http%3A%2F%2...2FarticleX.php
> >
> > And I guess you test locally, that's why you get htt://localhost in[/color][/color]
front[color=blue]
> of[color=green]
> > the url everytime.
> >
> > Savut
> >
> > "Martman" <martman100@nospam.insightbb.com> wrote in message
> > news:31Jcc.208068$po.1041362@attbi_s52...[color=darkred]
> > >I am new to PHP but testing the ability to read an RSS xml feed. I have
> > > successfully retrieved, read, and displayed an RSS feed from pcworld.
> > > However, when you click on one of the links it adds
http://localhost[/color][/color][/color]
to[color=blue][color=green][color=darkred]
> > > the
> > > link located in the xml file. If I view source in the browser[/color][/color][/color]
everything[color=blue][color=green][color=darkred]
> > > appears okay.
> > >
> > > Does anyone know of a configuration in the apache or php config files[/color][/color]
> that[color=green][color=darkred]
> > > automatically adds
http://localhost to hyperlinks?
> > >
> > > If not, has anyone seen any similar problems while reading an xml[/color][/color][/color]
feed?[color=blue][color=green][color=darkred]
> > >
> > > Thanks
> > > Marty U.
> > >
> > >[/color]
> >[/color]
>
>[/color]