1 | $data = $xml ->xpath( "//book/@msg" );
|
登录后复制
上面一段code会输出如下内容
array(1) { [0]=> object(SimpleXMLElement)#9 (1) { ["@attributes"]=> array(1) { ["msg"]=> string(24) "小王子" } } }
请问如何让它只返回msg里边的内容,而不返回数据路径"@attributes
回复讨论(解决方案)
1 | $data = $xml ->xpath( "//book/@msg" ); $str = (string) $data [0];
|
登录后复制