我正在尝试为以下帖子 xml 中的第一个 img 选择 src。
<post>
<regular-title>Testing 1</regular-title>
<regular-body>
<p>This is a test for projects on the website</p>
<p><img src="http://media.tumblr.com/tumblr_m3t0r3saXy1rocfxw.jpg"/></p>
<p><img src="http://media.tumblr.com/tumblr_m3t0s6bPyw1rocfxw.jpg"/></p>
</regular-body>
</post>
我可以使用 php 选择标题和发布文本,但我无法选择 img 或其 src。
$title = $xml->posts->post->{'regular-title'};
$img = $xml->posts->post->{'regular-body'}->??????;
$post = $xml->posts->post->{'regular-body'};
我使用正确的方法来选择 img 还是有其他方法?