我有xml文件,我正在用curl抓取它,然后得到
string(3781) "
<?xml version="1.0" encoding="utf-8"?>
<!--
Generated by e-racuni.com
Release number: 791.2
Release date: 10.09.2019
Request URL: /WebServicesHR/API
-->
<response status="ok">
<SalesInvoice>
<advanceInvoicesRef></advanceInvoicesRef>
<amountAlreadyPaid>-90</amountAlreadyPaid>
<amountLeftToBePaid>0</amountLeftToBePaid>
<bankAccountNumber>HR5623600001101883472</bankAccountNumber>
<businessUnit>0000</businessUnit>
<businessYear>2019</businessYear>
<buyerCountry>HR</buyerCountry>
<buyerName></buyerName>
<buyerVatRegistration>Unknown</buyerVatRegistration>
<city>Zagreb</city>
</SalesInvoice>
</response>
"
我尝试使用simplexml_load_string,但是我只得到这样的值
object(SimpleXMLElement)#1 (1) { [0]=> string(2869) " -90 0
HR5623600001101883472 0000 2019 HR Unknown Zagreb
$url = "http://www.elektroprofi.hr/api/demo.php";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_FAILONERROR,1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_TIMEOUT,3);
$result = curl_exec($ch);
curl_close($ch);
$response = simplexml_load_string($result);
var_dump($response);
如果有人可以帮助我,我会对此感到陌生,这真令人困惑,我希望得到类似[city] => zagreb,[date] => 2019-02-04