Solved

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

Posted on 2008-10-10
6
388 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

776 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