PHP 读取 XML 属性 [英] PHP read XML properties
本文介绍了PHP 读取 XML 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下由网络服务生成的 XML 数据
I have the following XML data which is generated by a webservice
<?xml version="1.0" encoding="UTF-8"?>
<rsp xmlns="http://worldcat.org/xid/isbn/" stat="ok">
<isbn oclcnum="263710087 491996179 50279560 60857040 429386124 44597307" lccn="00131084" form="AA BC" year="2002" lang="eng" ed="1st American ed." title="Harry Potter and the goblet of fire" author="J.K. Rowling." publisher="Scholastic Inc." city="New York [u.a.]" url="http://www.worldcat.org/oclc/263710087?referer=xid">9780439139601</isbn>
</rsp>
我需要读取isbn"标签中的数据,更具体地说,是title"属性的值.我将如何在 PHP 中执行此操作.
I need to read the data in the 'isbn' tag, more specifically, the value of the property 'title'. How would I do this in PHP.
谢谢
推荐答案
我自己解决了这个问题.
I have solved this myself.
$xmldata= file_get_contents("http://xisbn.worldcat.org/webservices/xid/isbn/9780439139601?method=getMetadata&format=xml&fl=*");
$xml= new SimpleXMLElement($xmldata);
print $xml->isbn[0]['title'];
这篇关于PHP 读取 XML 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文