Solved

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

Posted on 2008-10-10
6
392 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Cookie not unsetting 7 27
AJAX pass along a variable 3 46
Need to remove %20 from url in get 17 36
How to make a good PHP + MySQL + JS pagination system? 3 33
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.  …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

829 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