【发布时间】:2020-02-12 03:40:52
【问题描述】:
我想从特定节点的远程站点上的 XML 文件中获取数据。但是我收到以下错误
警告:simplexml_load_file(): 在 php 行中
关于警告 2:它正在加载文件数据。我想要的结果是获得 Grate。
注意:我在我的 php 安装中启用了 SimpleXML 模块。
<?php
$url = "http://api.srinivasajewellery.com/getrate/getrate";
$xml = simplexml_load_file($url) or die("not open");
?><pre><?php //print_r($xml); ?></pre><?php
foreach($xml->GRate as $GRate){
printf('$GRate');
}
?>
我希望在我的输出中得到“3640.00”,但错误如下
警告:simplexml_load_file():http://api.srinivasajewellery.com/getrate/getrate:1: 解析器错误:需要开始标记,在 H:\root\home\srinivasauser-001\www\goldrate\wp-content\themes\twentynineteen\footer 中找不到“
警告:simplexml_load_file(): {"Grate":"3640.00","SRate":"49.00","PRate":"0.00"} 在 H:\root\home\srinivasauser-001\www\goldrate\ wp-content\themes\twentynineteen\footer.php 在第 24 行
警告:simplexml_load_file(): ^ in H:\root\home\srinivasauser-001\www\goldrate\wp-content\themes\twentynineteen\footer.php 第 24 行 没有打开。
【问题讨论】: