0

我有这个 xml 内容。我需要从 fullName 属性中获取值。我已经尝试使用 lib.xml 解析器。但它不起作用。你能帮我实现这个目标吗?提前致谢。

<?xml version="1.0" encoding="UTF-8"?><currentUserDetails firstName="3rdParty" fullName="3rdParty Access" lastName="Access" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="" xmlns=""/>
4

2 回答 2

4

使用simplexml

$xml = simplexml_load_string($x); // assuming XML in $x
echo $xml['fullName'];

看到它工作:http ://codepad.viper-7.com/7KVHcU

于 2013-04-26T10:14:13.867 回答
0
$xmlFile   = "http://www.domaine.com/city.xml";

$data      = simplexml_load_file($xmlFile);

print_r($data);
于 2013-04-26T10:28:17.377 回答