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' />
를 추출?
나는 이것을 추출하는 방법을 모르지만, 나는 쉽게 제목을 추출 할 수있다. 그러나 나는 링크 대체와 같은 것을 어떻게하는지, 조언 해 주셔서 감사한다.
$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