- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 PHP 代码如下所示,显示空白 我想显示所有带有超链接的记录,例如
<a href="test.php?id=$Id">$Name</a>
$path = 'www.abc.com/test.xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $path);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$returned = curl_exec($ch);
curl_close($ch);
// $xml === False on failure
$xml = simplexml_load_string($returned);
foreach( $xml->Name as $Name){
print (string)$Name;
}
<ABCXml version="1.1.0">
<Manufacturers>
<Item>
<Id>219</Id>
<Name>Matrix Corp</Name>
</Item>
<Item>
<Id>2040</Id>
<Name>Microcomputer</Name>
</Item>
</Manufacturers>
</ABCXml>
最佳答案
您的 xml 对象以制造商开头,其中包含多个包含名称和 ID 的项目。你需要找到他们。
foreach($xml->Manufacturers->Item as $item) {
printf("<a href='test.php?id=%s>%s</a>", $item->Id, $item->Name);
}
关于php - simplexml_load_string foreach 不显示任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15712483/
有谁知道我是否可以强制 SimpleXMLElement 变量始终为数组? 1 name 1 2 nam
我目前正在尝试从谷歌联系人 api 中提取信息。使用库中提供的示例代码: $response = json_encode(simplexml_load_string($val->getResponse
我正在使用此代码读取 xml。 $xml = simplexml_load_string($data); 它读取正确,并且可以通过 $xml->title 等访问数据。 但我需要访问 CDATA 和
我正在尝试加载解析 Google Weather API 响应(中文响应)。 Here是 API 调用。 // This code fails with the following error $xm
调用未定义函数simplexml_load_string() 我在我们服务器上的所有站点上都遇到了这个错误。直到今天一切都正常工作,突然间出现了这个错误。 我检查了 Simplexml,它已经安装在服
我正在处理一个 xml 文件,我试图将其解析为 json 格式,然后解码为一个数组。我主要使用内置的 simplexml_load_string 和 json_encode 来完成此操作。问题是在调用
当我使用 simplexml_load_string 时,我发现一个问题,使用后丢失数据。 $xml = ' Dan He BMA * : An Efficient Algorithm for t
我正在使用 cron 文件实现 facebook 计数功能。其中 cron 每 10 分钟运行一次,并计算一个页面的总点赞数。 for($i=0;$ilink_stat->like_count;
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界. 这篇CFSDN的博客文章PHP simplexml_load_string()函数实例讲解由作者
我的 PHP 代码如下所示,显示空白 我想显示所有带有超链接的记录,例如 $Name 其中 $Id, $Name 来自 XML 提要 $path = 'www.abc.com/test.xml';
未插入值,也未显示错误。知道我的插入发生了什么吗? AD Andorra AE United Arab Emirates 784 AF Afghanistan 784 XML; $x
我阅读了以下 xml 文件: BO1 BO2 使用以下代码时: $xmlResponse = file_get_conte
我想将一个 xml 文件放入我的程序并将其放入一个数组中,这样我就可以将它放入一个表中。 我想知道如何做到这一点,我已经阅读了 php 手册,但我似乎无法掌握它。 做我想做的事,我需要使用simple
常量 XML_PARSE_HUGE 可以作为第三个参数传递给 simplexml_load_string() .根据php.net这个标志: relaxes any hardcoded limit f
我试图在 Python 中找到一个 xml 解释函数(如 simplexml_load_string),但没有成功:/ 假设我有一个字符串中的 xml my_xml_string = """
我正在处理一个我无法编辑的第三方 PHP 库,它已经运行了将近一年。它对来自远程服务器的响应使用 simplexml_load_string。最近,它因大量响应而窒息。这是房地产列表的数据提要,格式如
我见过很多程序员实现 SimpleXML_load_string() 而不是 SimpleXMLElement() 类。使用前者比使用后者有什么好处吗?我读过 PHP manual on simple
我正在使用以下 PHP 代码从 NOAA 的潮汐报告站 API 读取 XML 数据: $rawxml = file_get_contents( "http://opendap.co-ops.n
这个问题在这里已经有了答案: 关闭 9 年前。 Possible Duplicate: Accessing @attribute from SimpleXML 我正在使用一些第三方 API,它们通过
所以我有一个 PHP 脚本,它解析来自 Google Analytics 的 XML 响应。它已经工作了几个星期,但今天我收到了这个警告,简单的 xml 加载字符串没有将 xml 响应转换为 simp
我是一名优秀的程序员,十分优秀!