Solved

indeed.com's parsed XML data has "&" character missing from url link

Posted on 2008-10-10
6
398 Views
Last Modified: 2008-10-11
Hi, I have developed an app getting indeed.com's XML data to be listed. The funny thing is only one of my client is having this problem, for example the XML data containing link info returned:

The problem data:

http://api.indeed.com/viewjob?jk=59f2ee1649a79789qd=

The normal data should be:

http://api.indeed.com/viewjob?jk=59f2ee1649a79789&qd=

as you can see the character "&" is missing at the end part "&qd=". It is happending to the rest of the line too that should have various "&" to separate the $_GET variables. So I believe only his server settings is causing this problem because I have tested in various different servers from different hosting company without  having this problem. But I need to know what kind of PHP or Apache settings might cause this? The PHP XML functions used are:

      $parser = xml_parser_create();

      $db_data = array();

      xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);

      xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);

      xml_parse_into_struct($parser, $data, $values, $tags);


The PHP version is 5.2.6 (both the server with problem and the ones without the problem)


Thank you.
0
Comment
Question by:santocki
  • 4
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Xyptilon2
ID: 22693665
Nothing comes to mind, perhaps a magic_quote setting in php.ini, but I also doubt that.
0
 

Author Comment

by:santocki
ID: 22693805
I checked the magic quote settings, but both servers (working and non-working) are set as

magic_quotes_gpc      On      On
magic_quotes_runtime      Off      Off
magic_quotes_sybase      Off      Off


so it's not that problem.
0
 
LVL 13

Accepted Solution

by:
Xyptilon2 earned 500 total points
ID: 22693824
I dont think the problem lies in the generation of the XML, how are the URLs formed? What code do you use for that?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:santocki
ID: 22694180
Okay, while I was testing, I was able to narrow down the problem to this code:

   $what = "php programmer";
   $where = "california, ca";

    $xml_url      = 'http://api.indeed.com/apisearch?key='.$indeed_key.

                                                   '&q='.urlencode($what).

                                                   '&l='.urlencode($where).

                                                   '&highlight=false&start=1';


    $data = implode('', file($xml_url));



When I display the $data variable data like

     echo $data

The server with problem will have url having "&" character stripped. So now, the question is, what kind of server settings would affect PHP's file() function to strip out "&" when fetching the remote page?

Thanks.
0
 

Author Comment

by:santocki
ID: 22694224
Okay, I have found the solution, there was a problem in the code. Thanks for the assistance.
0
 

Author Comment

by:santocki
ID: 22694331
Sorry, I've made a mistake. It still did not solve the problem. If you can help, then I would be glad. I came to narrow the problm at:

    $data = implode('', file($filename));

    echo $data; // >>>>>>>>>> it shows the data with "&" correctly

    $parser = xml_parser_create();

    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parse_into_struct($parser, $data, $values, $tags);

   print_r($values); // >>>>>>>>>>>> now the "&" is stripped out

I have tried all the xml_parser_set_option() options, but without success. Must be some kind of PHP settings... confused. It only happens in one of my customer's server.

Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question