php - How to read in XML strings as variables? -


this question has answer here:

try query:

http://www.dictionaryapi.com/api/v1/references/collegiate/xml/gobabola?key=135a6187-af83-4e85-85c1-1a28db11d5da

how read in suggestions variables? can't seem find explains this.

you can use simplexmliterator. that's easy use , able perform foreach on object get.

library source

for example file_get_contents or replace curl if prefer:

    $feed = new simplexmliterator(file_get_contents('http://www.dictionaryapi.com/api/v1/references/collegiate/xml/gobabola?key=135a6187-af83-4e85-85c1-1a28db11d5da'));     foreach ($feed->suggestion $suggestion) {         echo $value;       } 

Comments