Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8890041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:24:34+00:00 2026-06-14T22:24:34+00:00

I’m trying to use Yahoo’s content analysis, which seems really easy to use from

  • 0

I’m trying to use Yahoo’s content analysis, which seems really easy to use from here

But whenever I execute my code, I get the following output, as it is:

Italian sculptors the Virgin Mary painters http://en.wikipedia.com/wiki/Painting http://en.wikipedia.com/wiki/Adobe_Photoshop http://en.wikipedia.com/wiki/Still_life http://en.wikipedia.com/wiki/Avant-garde http://en.wikipedia.com/wiki/In_the_Sky http://en.wikipedia.com/wiki/Potato 1

What I want is to see an XML document structured with the XML tags just like the way it appears when you click this link

Also, the source code (from the browser.. the right click>view source thing) of what I’m seeing as the output is:

<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="1" yahoo:created="2012-11-24T05:54:55Z" yahoo:lang="en-US"><results><entities xmlns="urn:yahoo:cap">
    <entity score="0.784327">
      <text end="16" endchar="16" start="0" startchar="0">Italian sculptors</text>
    </entity>
    <entity score="0.78097">
      <text end="72" endchar="72" start="58" startchar="58">the Virgin Mary</text>
    </entity>
    <entity score="0.509566">
      <text end="29" endchar="29" start="22" startchar="22">painters</text>
      <wiki_url>http://en.wikipedia.com/wiki/Painting</wiki_url>
      <related_entities>
        <wikipedia>
          <wiki_url>http://en.wikipedia.com/wiki/Adobe_Photoshop</wiki_url>
          <wiki_url>http://en.wikipedia.com/wiki/Still_life</wiki_url>
          <wiki_url>http://en.wikipedia.com/wiki/Avant-garde</wiki_url>
          <wiki_url>http://en.wikipedia.com/wiki/In_the_Sky</wiki_url>
          <wiki_url>http://en.wikipedia.com/wiki/Potato</wiki_url>
        </wikipedia>
      </related_entities>
    </entity>
  </entities></results></query><!-- total: 191 -->
<!-- engine6.yql.ac4.yahoo.com -->
1

Following is my code :

<?php
$c = curl_init();
curl_setopt($c, CURLOPT_URL, 'http://query.yahooapis.com/v1/public/yql');
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, "q=select * from contentanalysis.analyze where text='Italian sculptors and painters of the renaissance favored the Virgin Mary for inspiration';");
curl_setopt($c,CURLOPT_HEADER,0);
$op=curl_exec ($c);
curl_close ($c); 
echo $op;
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:24:35+00:00Added an answer on June 14, 2026 at 10:24 pm

    That is how XML is displayed in the browser when the header being sent is Content-type: text/html. The demo example you link to that shows formatted XML uses some special formatting to get it looking like that. You need to set the header to be text/xml like header('Content-type: text/xml'); and then the output should display formatted.

    header('Content-type: text/xml');
    echo $op;
    

    You can also output your content like so:

    echo '<pre>';
    echo htmlentities($op);
    echo '</pre>';
    

    The above explains why XML shows up unformatted in the browser and demonstrates how to fix that. The OP’s main problem is that his XML is malformed due to that stray string at the the end of the output. The following deals with that:

    $r = 'http://query.yahooapis.com/v1/public/yql';
    $p = "q=select * from contentanalysis.analyze where text='Italian sculptors and painters of the renaissance favored the Virgin Mary for inspiration'"; 
    
    $c = curl_init($r);
    curl_setopt($c, CURLOPT_POST, true);
    curl_setopt($c, CURLOPT_POSTFIELDS, $p);
    curl_setopt($c, CURLOPT_HEADER, true);
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    $op = curl_exec ($c);
    curl_close ($c); 
    
    if (!($xml = strstr($op, '<?xml'))) {
        $xml = null;
    }
    
    header('Content-type: text/xml');
    echo $xml;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to select an H1 element which is the second-child in its group
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.