-1

Possible Duplicate:
Extracting HTML from an XML file using simpleXML

I am trying to apply Wolfram Alpha API to my project and I am really stuck on this problem.

The return data from their server is xml, but I am not sure how to display the data in my browser.

I want to display tag and <img> tag under <subpod> tag using php but not sure how to do this.

Can anyone help me out on this one? Thanks a lot!

<?xml version='1.0' encoding='UTF-8'?>
<queryresult success='true'
    error='false'
    numpods='4'
    datatypes='Word'
    timedout='Data,Character'
    timedoutpods=''
    timing='1.566'
    parsetiming='0.116'
    parsetimedout='false'
    recalculate='http://www4b.wolframalpha.com/api/v2/recalc.jsp?id=MSPa17571a3db4591h53ha1200000d7e8c604egche19&amp;s=10'
    id='MSPa17581a3db4591h53ha1200005hcfi072h5329b57'
    host='http://www4b.wolframalpha.com'
    server='10'
    related='http://www4b.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa17591a3db4591h53ha12000065e4habf2bag446e&amp;s=10'
    version='2.6'>
 <pod title='Input interpretation'
     scanner='Identity'
     id='Input'
     position='100'
     error='false'
     numsubpods='1'>
  <markup><![CDATA[<div id="pod_0100" class="pod "><hr class="top" /><h2>
      Input interpretation<span class="colon">:</span></h2><ul class="h"></ul><div id="subpod_0100_1" class="sub "><div class="output pnt" id="scannerresult_0100_1"><img height="18"width="163" src="http://www4b.wolframalpha.com/Calculate/MSP/MSP17631a3db4591h53ha1200001i123763cde8fada?MSPStoreType=image/gif&s=10&amp;w=163&amp;h=18" id="i_0100_1" alt="common  (English word)" title="common  (English word)"  data-attribution="" /></div><div class="annotpod">
    </div></div>
<hr class="bot" /></div>]]></markup>
  <subpod title=''>
   <img src='http://www4b.wolframalpha.com/Calculate/MSP/MSP17641a3db4591h53ha1200004eg12d5dbfca04h8?MSPStoreType=image/gif&amp;s=10'
       alt='common  (English word)'
       title='common  (English word)'
       width='163'
       height='18' />
  </subpod>
 </pod>


......more
Community
  • 1
  • 1
FlyingCat
  • 14,036
  • 36
  • 119
  • 198

1 Answers1

0

It's very easy

$xml = new SimpleXMLElement($xml);
var_dump($xml->pod->subpod->img);
Baba
  • 94,024
  • 28
  • 166
  • 217