SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist
    Join Date
    Nov 2009
    Posts
    471
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    data return from Yahoo PlaceFinder

    In a simple example of geocoding with Yahoo placefinder, I am getting a return but my understandinig is the return is supposed to be xml. I am just getting a plain string. Am I supposed to be setting something else? I am under the impression their return default is xml. While I can certainly parse the string to find lat/long, anything else would be difficult I think.

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "where.yahooapis.com/geocode?location=15+marrett+rd,+lexington,+ma&appid=xxxx");
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    $output = curl_exec($ch);
    curl_close($ch);

    echo "<pre>";
    var_dump($output);
    die();

    Any ideas how to get this in an xml format?

  2. #2
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    61 Post(s)
    Tagged
    0 Thread(s)
    Don't output the $output as HTML else you won't see it properly! Before you output anything write the line ini_set('default_mimetype', 'text/plain'); (you also won't need the <pre> tag).
    Salathe
    Software Developer and PHP Manual Author.

  3. #3
    SitePoint Evangelist
    Join Date
    Nov 2009
    Posts
    471
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks. That works great.

  4. #4
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    61 Post(s)
    Tagged
    0 Thread(s)
    For what it's worth, you can also set that INI option within your php.ini file (on the server/computer that you develop your code on) to output, by default, as plain text. The default of HTML (text/html) can be exceptionally annoying and is the cause of lots of questions like yours here.
    Salathe
    Software Developer and PHP Manual Author.

  5. #5
    SitePoint Evangelist
    Join Date
    Nov 2009
    Posts
    471
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Stupid question, set it to "text" or "plain text"?

  6. #6
    SitePoint Evangelist
    Join Date
    Nov 2009
    Posts
    471
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind, it's "text/plain", correct?

  7. #7
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Salathe View Post
    Don't output the $output as HTML else you won't see it properly! Before you output anything write the line ini_set('default_mimetype', 'text/plain'); (you also won't need the <pre> tag).
    Salathe has already pointed it out.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •