PHP Retrieve DATA from XML

后端 未结 4 521
盖世英雄少女心
盖世英雄少女心 2021-01-24 06:13

My first attempt at retrieving data from XML for a maps application has failed. Here is a piece of the XML Feed.

         


        
4条回答
  •  我在风中等你
    2021-01-24 06:39

    Haven't tested your specific case, but i remember running into something similar when using SimpleXML, you might want to use (string) to cast it out of the object

    array('output'=> (string)$start[0])
    

    Or rather just leave out $start = array($start) and just do

    array('output'=> (string)$start)
    

    On reading the SimpleXML XPath documentation (http://www.php.net/manual/en/simplexmlelement.xpath.php) again i think your problem might be this:

    Returns an array of SimpleXMLElement objects or FALSE in case of an error.
    

    So the XPath returns an array, then you wrap that in an array and take the first element of that array, so all you end up with is the original array - remove the array wrap and you should be fine

提交回复
热议问题