Php 从二维xml字符串中获取键值

Php 从二维xml字符串中获取键值,php,xml,Php,Xml,我想从字符串中读取一些值。字符串现在是xml格式。 我怎样才能从中得到艺术家 <?xml version="1.0" encoding="UTF-8" ?> <song> <filename>c699da47ed08bd80927ae148c1b5b0fd.mp3</filename> <title>Interlude (Imam Siraj)</title> <artist>Native Deen</ar

我想从字符串中读取一些值。字符串现在是xml格式。 我怎样才能从中得到艺术家

<?xml version="1.0" encoding="UTF-8" ?>
<song>
<filename>c699da47ed08bd80927ae148c1b5b0fd.mp3</filename>
<title>Interlude (Imam Siraj)</title>
<artist>Native Deen</artist>
<album>Not Afraid To Stand Alone</album>
<year>2007</year>
<genre>R&B</genre>
<duration>0:01:20 (approx)</duration>
</song>

c699da47ed08bd80927ae148c1b5b0fd.mp3
插曲(伊玛目·西拉吉)
土鹿
不怕孤独
2007
R&B
0:01:20(约)
我已经尝试过使用simplexml,但不知道如何在其中获取元素

$xml=simplexml\u load\u字符串($strXML); $strArtist=???

请阅读手册


$strArtist=$xml->artist

是的,谢谢。我一直在尝试调用这样的对象,甚至还尝试了loadfile函数,以防xml字符串的格式不正确。它仍然不起作用。打印($xml)甚至不起作用。我开始认为简单xml甚至没有安装在我的MacOSX工作台上,但它不会抛出任何错误。