- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
大家好,我正在尝试从这个 XML 中获取所有艺术家:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<metadata created="2015-02-03T04:03:18.468Z"
xmlns="http://musicbrainz.org/ns/mmd-2.0#"
xmlns:ext="http://musicbrainz.org/ns/ext#-2.0">
<artist-list count="6310" offset="0">
<artist id="d51955f3-df06-432c-a90d-0308f3c48273" type="Person" ext:score="100">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<gender>male</gender>
<country>US</country>
<area id="489ce91b-6658-3307-9877-795b68554c98">
<name>United States</name>
<sort-name>United States</sort-name>
</area>
<begin-area id="82f3a697-ba65-404d-a1ed-360147af7d10">
<name>San Diego</name>
<sort-name>San Diego</sort-name>
</begin-area>
<end-area id="ae0110b6-13d4-4998-9116-5b926287aa23">
<name>California</name>
<sort-name>California</sort-name>
</end-area>
<disambiguation>jazz pianist, composer, arranger and bandleader</disambiguation>
<life-span>
<begin>1922-04-17</begin>
<end>2013-06-29</end>
<ended>true</ended>
</life-span>
<alias-list>
<alias sort-name="Smith, Paul T.">Paul T. Smith</alias>
</alias-list>
</artist>
<artist id="443ead81-02ce-4136-a759-71453184c002" type="Person" ext:score="100">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<gender>male</gender>
<country>US</country>
<area id="489ce91b-6658-3307-9877-795b68554c98">
<name>United States</name>
<sort-name>United States</sort-name>
</area>
<begin-area id="f83bde89-c84a-4846-a89a-d5d0874e9ddc">
<name>Calumet</name>
<sort-name>Calumet</sort-name>
</begin-area>
<end-area id="6db2e45d-d7f3-43da-ac0b-7ba5ca627373">
<name>Glendale</name>
<sort-name>Glendale</sort-name>
</end-area>
<disambiguation>film and television composer, Disney Legends honoree</disambiguation>
<life-span>
<begin>1906-10-30</begin>
<end>1985-01-25</end>
<ended>true</ended>
</life-span>
<alias-list>
<alias sort-name="Smith, Paul J.">Paul J. Smith</alias>
</alias-list>
</artist>
<artist id="fac3e6c4-6d3c-4086-a590-95e4a057ac42" ext:score="95">
<name>Paul Smith</name>
<sort-name>Paul Smith</sort-name>
<disambiguation>Banjo</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="8ffc42c7-4083-4435-b91c-6ddf4095eeb3" ext:score="95">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<country>US</country>
<area id="489ce91b-6658-3307-9877-795b68554c98">
<name>United States</name>
<sort-name>United States</sort-name>
</area>
<disambiguation>American soul artist</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="2f727018-1e83-4797-8433-32c8b99dd057" type="Person" ext:score="94">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<gender>male</gender>
<country>GB</country>
<area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
<name>United Kingdom</name>
<sort-name>United Kingdom</sort-name>
</area>
<disambiguation>of Maxïmo Park</disambiguation>
<life-span>
<begin>1979-03-13</begin>
<ended>false</ended>
</life-span>
</artist>
<artist id="e44ae2fa-9367-4691-bdb7-d097446ee3ce" type="Person" ext:score="94">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<disambiguation>Gabba/Acid techno artist</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="32c7cf45-867e-4076-a24c-ba38dccaa7bd" type="Person" ext:score="94">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<country>US</country>
<area id="489ce91b-6658-3307-9877-795b68554c98">
<name>United States</name>
<sort-name>United States</sort-name>
</area>
<disambiguation>American folk artist</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="bb57b210-bf27-4af1-8561-600f131bfc81" type="Person" ext:score="94">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<disambiguation>drum n bass producer aka Spinback</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="35287ce6-2fd4-41af-9248-d07e84eeb0df" type="Person" ext:score="94">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<disambiguation>Contemporary Christian artist peformed with The Imperials</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="6ece7fa3-c397-48a6-99f7-05e900b73d81" type="Person" ext:score="82">
<name>Nicholas Paul Smith</name>
<sort-name>Smith, Nicholas Paul</sort-name>
<gender>male</gender>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="3c1fbcf7-4bb8-49ac-8d35-3f4ee8b71e0a" type="Person" ext:score="79">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<gender>male</gender>
<country>US</country>
<area id="489ce91b-6658-3307-9877-795b68554c98">
<name>United States</name>
<sort-name>United States</sort-name>
</area>
<disambiguation>recording engineer, David "Honeyboy" Edwards recordings</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="24e472f9-6003-4873-aac5-c79763105a51" type="Person" ext:score="79">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<gender>male</gender>
<country>GB</country>
<area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
<name>United Kingdom</name>
<sort-name>United Kingdom</sort-name>
</area>
<disambiguation>UK drummer</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="662c9cd6-73e2-426f-8e76-a8f2a8233215" type="Person" ext:score="79">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<country>AU</country>
<area id="106e0bec-b638-3b37-b731-f53d507dc00e">
<name>Australia</name>
<sort-name>Australia</sort-name>
</area>
<disambiguation>Australian bassist for Laughing Clowns/Ed Kuepper</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="0e911646-290a-4345-b3dc-e5ca91faaf88" type="Person" ext:score="79">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<gender>male</gender>
<country>GB</country>
<area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
<name>United Kingdom</name>
<sort-name>United Kingdom</sort-name>
</area>
<disambiguation>British a cappella singer</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="75ffe808-187a-4488-8c84-7467efa2b277" type="Person" ext:score="79">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<disambiguation>of Dengue Fever</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="79d145cb-d862-487d-a340-b723a7c8eb26" type="Person" ext:score="79">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<country>GB</country>
<area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
<name>United Kingdom</name>
<sort-name>United Kingdom</sort-name>
</area>
<disambiguation>Scottish electronic artist performing as Reverbaphon</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="1f483d17-7510-44d1-95a7-8c16c53c57a1" type="Person" ext:score="79">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<country>US</country>
<area id="489ce91b-6658-3307-9877-795b68554c98">
<name>United States</name>
<sort-name>United States</sort-name>
</area>
<disambiguation>US underground hip hop MC Breeze Brewin, of Weatherman, Def Jux</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="76e04e2a-e440-4729-8036-59928521c677" type="Person" ext:score="79">
<name>Paul Smith</name>
<sort-name>Smith, Paul</sort-name>
<gender>male</gender>
<country>US</country>
<area id="489ce91b-6658-3307-9877-795b68554c98">
<name>United States</name>
<sort-name>United States</sort-name>
</area>
<disambiguation>sound engineer, Randy Crawford & Joe Sample recordings</disambiguation>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="7a81a64e-4fdc-44a8-b33b-a447c611cf33" type="Group" ext:score="76">
<name>The Paul Smith Trio</name>
<sort-name>Paul Smith Trio, The</sort-name>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="7b458c24-ce5b-4b77-a1dc-616ff53d1e70" type="Group" ext:score="76">
<name>The Paul Smith Quartet</name>
<sort-name>Paul Smith Quartet, The</sort-name>
<country>US</country>
<area id="489ce91b-6658-3307-9877-795b68554c98">
<name>United States</name>
<sort-name>United States</sort-name>
</area>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="1c86fcf3-b56c-4427-856b-344d898abc33" ext:score="76">
<name>Paul Gerard Smith</name>
<sort-name>Smith, Paul Gerard</sort-name>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="e5fcb860-3210-4721-a44f-7bd3dcb4b5d5" ext:score="76">
<name>Paul Joseph Smith</name>
<sort-name>Paul Joseph Smith</sort-name>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="3eedd38b-f7ca-43d2-b635-adc4ad95371b" type="Person" ext:score="74">
<name>Margaret Thatcher</name>
<sort-name>Thatcher, Margaret</sort-name>
<gender>female</gender>
<country>GB</country>
<area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
<name>United Kingdom</name>
<sort-name>United Kingdom</sort-name>
</area>
<life-span>
<begin>1925-10-13</begin>
<end>2013-04-08</end>
<ended>true</ended>
</life-span>
<tag-list>
<tag count="1">
<name>politician</name>
</tag>
<tag count="1">
<name>non-musician</name>
</tag>
</tag-list>
</artist>
<artist id="646c86db-d0af-403e-bef9-3deafd9c3d43" type="Person" ext:score="74">
<name>Brad Thatcher</name>
<sort-name>Thatcher, Brad</sort-name>
<life-span>
<ended>false</ended>
</life-span>
</artist>
<artist id="b5425c52-3e9c-4144-9467-eaa4d69389b8" type="Person" ext:score="74">
<name>Jim Thatcher</name>
<sort-name>Thatcher, Jim</sort-name>
<life-span>
<ended>false</ended>
</life-span>
<alias-list>
<alias sort-name="Thatcher, James" type="Legal name">James Thatcher</alias>
</alias-list>
</artist>
</artist-list>
</metadata>
<!doctype html>
<html>
<head>
<body>
<meta charset="utf-8">
<title>XML: Descrizione, Immagine, Link a Discogs</title>
</head>
<body>
<?php
$bb = "Paul Thatcher Smith"; //Example.
$name = strtolower(str_replace(" ","%20",$bb)); //all whitespaces must be coded with %20
$html = "http://musicbrainz.org/ws/2/artist/?query=".$name;
if (($response_xml_data = file_get_contents($html))===false){
echo "Error fetching XML\n";
}
else {
libxml_use_internal_errors(true);
$data = new SimpleXmlElement($response_xml_data); //all ok, you can do an echo, xml is well formed
$data->registerXPathNamespace('c',$html); //according to w3s
if (!$data) { //always have this error -.-
echo "Error loading XML\n";
foreach(libxml_get_errors() as $error) {
echo "\t", $error->message;
}
}
else {
$xpath='//c:artist'; //simple xpath query, if i put //* it gives me all xml
print_r($result = $data->xpath($xpath));
foreach ($result as $artist){
echo $artist . "<br>";
}
}
}
?>
最佳答案
此行不正确:
$data->registerXPathNamespace('c',$html);
$html
是您正在查询的 URL,但在这一行中,您需要指定您正在使用的 XML 的命名空间。该命名空间是:
http://musicbrainz.org/ns/mmd-2.0#
$data->registerXPathNamespace('c','http://musicbrainz.org/ns/mmd-2.0#');
关于php - 在php中使用Xpath,返回一个空数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28281796/
我在 JavaScript 文件中运行 PHP,例如...... var = '';). 我需要使用 JavaScript 来扫描字符串中的 PHP 定界符(打开和关闭 PHP 的 )。 我已经知道使
我希望能够做这样的事情: php --determine-oldest-supported-php-version test.php 并得到这个输出: 7.2 也就是说,php 二进制检查 test.
我正在开发一个目前不使用任何框架的大型 php 站点。我的大问题是,随着时间的推移慢慢尝试将框架融入应用程序是否可取,例如在创建的新部件和更新的旧部件中? 比如所有的页面都是直接通过url服务的,有几
下面是我的源代码,我想在同一页面顶部的另一个 php 脚本中使用位于底部 php 脚本的变量 $r1。我需要一个简单的解决方案来解决这个问题。我想在代码中存在的更新查询中使用该变量。 $name)
我正在制作一个网站,根据不同的情况进行大量 PHP 重定向。就像这样...... header("Location: somesite.com/redirectedpage.php"); 为了安全起见
我有一个旧网站,我的 php 标签从 因为短标签已经显示出安全问题,并且在未来的版本中将不被支持。 关于php - 如何避免在 php 文件中写入
我有一个用 PHP 编写的配置文件,如下所示, 所以我想用PHP开发一个接口(interface),它可以编辑文件值,如$WEBPATH , $ACCOUNTPATH和 const值(value)观
我试图制作一个登录页面来学习基本的PHP,首先我希望我的独立PHP文件存储HTML文件的输入(带有表单),但是当我按下按钮时(触发POST到PHP脚本) )我一直收到令人不愉快的错误。 我已经搜索了S
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: What is the max key size for an array in PHP? 正如标题所说,我想知道
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我在 MySQL 数据库中有一个表,其中存储餐厅在每个工作日和时段提供的菜单。 表结构如下: i_type i_name i_cost i_day i_start i_
我有两页。 test1.php 和 test2.php。 我想做的就是在 test1.php 上点击提交,并将 test2.php 显示在 div 中。这实际上工作正常,但我需要向 test2.php
我得到了这个代码。我想通过textarea更新mysql。我在textarea中回显我的MySQL,但我不知道如何更新它,我应该把所有东西都放进去吗,因为_GET模式没有给我任何东西,我也尝试_GET
首先,我是 php 的新手,所以我仍在努力学习。我在 Wordpress 上创建了一个表单,我想将值插入一个表(data_test 表,我已经管理了),然后从 data_test 表中获取所有列(id
我有以下函数可以清理用户或网址的输入: function SanitizeString($var) { $var=stripslashes($var); $va
我有一个 html 页面,它使用 php 文件查询数据库,然后让用户登录,否则拒绝访问。我遇到的问题是它只是重定向到 php 文件的 url,并且从不对发生的事情提供反馈。这是我第一次使用 html、
我有一个页面充满了指向 pdf 的链接,我想跟踪哪些链接被单击。我以为我可以做如下的事情,但遇到了问题: query($sql); if($result){
我正在使用 从外部文本文件加载 HTML/PHP 代码 $f = fopen($filename, "r"); while ($line = fgets($f, 4096)) { print $l
我是一名优秀的程序员,十分优秀!