-1

可能重复:
使用 simpleXML 从 XML 文件中提取 HTML

我正在尝试将 Wolfram Alpha API 应用到我的项目中,但我真的陷入了这个问题。

从他们的服务器返回的数据是 xml,但我不知道如何在我的浏览器中显示数据。

我想使用 php<img>在标签下显示标签和标签,<subpod>但不知道该怎么做。

谁能帮我解决这个问题?非常感谢!

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

1 回答 1

0

这很容易

$xml = new SimpleXMLElement($xml);
var_dump($xml->pod->subpod->img);
于 2012-10-17T23:54:29.080 回答