php - Get specific tag from api code -
i want img src tag following code:
<pod title="scientific name" scanner="data" id="scientificname:speciesdata" position="200" error="false" numsubpods="1"> <subpod title=""> <plaintext>canis lupus familiaris</plaintext> <img src="http://www4a.wolframalpha.com/calculate/msp/msp17941cd1c5fi21h72ac2000057i1ae7gc4986gdf?mspstoretype=image/gif&s=44" alt="canis lupus familiaris" title="canis lupus familiaris" width="139" height="18"/> </subpod> </pod>
i know how plaintext information how img src information? here's have plaintext information:
<?php if(isset($_post['q'])){ include 'wolframalphaengine.php'; $engine = new wolframalphaengine( 'app-id' ); $resp = $engine->getresults("$q"); $pod = $resp->getpods(); $pod1 = $pod[1]; foreach($pod1->getsubpods() $subpod){ if($subpod->plaintext){ $plaintext = $subpod->plaintext; break; } } $result = substr($plaintext, 0,strlen($plaintext)-3); echo "$plaintext"; } ?>
it's not duplicate of grabbing href attribute of element because can't use dom on godaddy hosting. i've tried before.
i've never worked wolframalphaengine before. assume it's one:
if so, have @ https://github.com/brkeerthi/chethana/blob/master/include/wasubpod.php
class wasubpod { // define sections of response public $attributes = array(); public $plaintext = ''; public $image = ''; public $minput = ''; public $moutput = ''; public $mathml = '';
as can see, has properties not plaintext, attributes , other stuff. might easy
foreach ($pod1->getsubpods() $subpod) { $attributes = $subpod->attributes; if (isset($attributes['src']) { echo $attributes['src']; } }
but since documentation of library non-existent, cannot tell. if doesn't work, var_dump
$subpod
see contains.
likewise, have @ other classes find out do:
Comments
Post a Comment