如何解析来自Wolfram Alpha的数据



可能的重复:
使用Simplexml

从XML文件中提取HTML

我试图将wolfram alpha api应用于我的项目,我真的陷入了这个问题。

他们服务器的返回数据是XML,但我不确定如何在浏览器中显示数据。

我想使用php显示在<subpod>标签下显示标签和<img>标签,但不确定如何做。

有人可以帮我解决这个问题吗?非常感谢!

<?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

这很容易

$xml = new SimpleXMLElement($xml);
var_dump($xml->pod->subpod->img);

相关内容

  • 没有找到相关文章

最新更新