私は何時間もそれを理解しようとしてきました。str 属性のみを使用する XML からデータを取得しようとしています。使用しようとしている XML の例を次に示します。
<doc>
<str name="author">timothy</str>
<str name="author_s">timothy</str>
<str name="title">French Gov't Runs Vast Electronic Spying Operation of Its Own</str>
<arr name="category">
<str>communications</str>
</arr>
<str name="slash-section">yro</str>
<str name="description">Dscription</str>
<str name="slash-comments">23</str>
<str name="link">http://rss.slashdot.org/~r/Slashdot/slashdot/~3/dMLqmWSFcHE/story01.htm</str>
<str name="slash-department">but-it's-only-wafer-thin-metadata</str>
<date name="date">2013-07-04T15:06:00Z</date>
<long name="_version_">1439733898774839296</long></doc>
だから私の問題は、データを取得できないように見えることですこれで試しました:
<?php
$x = simplexml_load_file('select.xml');
$xml = simplexml_load_string($x);
echo $xml->xpath("result/doc/str[@name='author']")[0];
?>
サーバーでエラーが発生する
誰でも私を助けることができますか?