XMLからのデータ抽出に問題があります。値の抽出フォームXML
内容は次のようになります。
<entry>
<id>tag:blogger.com,1999:blog-227841964192642355.post-8872593151327492602</id>
<published>2016-08-15T01:56:00.001-07:00</published>
<updated>2016-08-15T01:56:36.304-07:00</updated>
<title type='text'>Podaj tytuł wpisu spintax</title>
<content type='html'>Treść wpisu spintax </content>
<link rel='replies' type='application/atom+xml' href='http://ecookingwithme.blogspot.com/feeds/8872593151327492602/comments/default' title='Komentarze do posta' />
<link rel='replies' type='text/html' href='http://ecookingwithme.blogspot.com/2016/08/podaj-tytu-wpisu-spintax.html#comment-form' title='Komentarze (0)' />
<link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/227841964192642355/posts/default/8872593151327492602' />
<link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/227841964192642355/posts/default/8872593151327492602' />
<link rel='alternate' type='text/html' href='I NEED THIS LINK' title='Podaj tytuł wpisu spintax' />
<author>
<name>NAMEa</name>
<uri>link here</uri>
<email>[email protected]</email>
<gd:image rel='link here' width='16' height='16' src='link here' />
</author>
<thr:total>0</thr:total>
</entry>
ホーデータ形式<link rel='alternate' type='text/html' href='I NEED THIS LINK' title='Podaj tytuł wpisu spintax' />
を抽出するために?
私はこれを抽出する方法はわかりませんが、簡単にタイトルを抽出することはできますが、LINKの代わりにアドバイスをしても同じことをする方法はわかりません。ここで
は私が書き込みを持っているものです。
$file = "http://ecookingwithme.blogspot.com/atom.xml";
$xml = simplexml_load_file($file);
echo $xml->entry->title;
また、私がしようとしている:
$file = "http://ecookingwithme.blogspot.com/atom.xml";
$xml = simplexml_load_file($file);
foreach ($xml->entry as $foo) {
foreach ($foo->link as $link) {
$type = (string) $link->attributes()->{'rel'};
if ($type == 'rel') {
echo (string) $link->attributes()->{'href'};
}
}
}
次のいずれかの回答が問題を解決していますか? http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – chris85