Php 从RSS提要获取属性(';标签';)
我想从这个rss源中获取分类标签,但无法完成。其他一切都完美无瑕 RSS源代码:Php 从RSS提要获取属性(';标签';),php,attributes,rss,getattribute,Php,Attributes,Rss,Getattribute,我想从这个rss源中获取分类标签,但无法完成。其他一切都完美无瑕 RSS源代码: <im:name>Quizduell</im:name> <link rel="alternate" type="text/html" href="https://itunes.apple.com/de/app/quizduell/id643791032?mt=8&uo=2"/> <im:contentType term="Application" label="P
<im:name>Quizduell</im:name>
<link rel="alternate" type="text/html" href="https://itunes.apple.com/de/app/quizduell/id643791032?mt=8&uo=2"/>
<im:contentType term="Application" label="Programm"/>
<category im:id="6014" term="Games" scheme="https://itunes.apple.com/de/genre/ios-spiele/id6014?mt=8&uo=2" label="Spiele"/>
<im:artist href="https://itunes.apple.com/de/artist/feo-media/id534160178?mt=8&uo=2">FEO Media</im:artist>
<im:price amount="0.00000" currency="EUR">Gratis</im:price>
Quizduell
FEO介质
免费的
我的PHP小部件代码:
$count = 0;
foreach ($doc->getElementsByTagName('entry') as $node) {
$count = $count + 1;
$title = htmlspecialchars($node->getElementsByTagName('name')->item(0)->nodeValue);
$id = ExtractID(utf8_encode($node->getElementsByTagName('id')->item(0)->nodeValue));
$price = htmlspecialchars($node->getElementsByTagName('price')->item(0)->nodeValue);
$sellerName = htmlspecialchars(($node->getElementsByTagName('artist')->item(0)->nodeValue));
$image = utf8_encode($node->getElementsByTagName('image')->item(0)->nodeValue);
$afflink = WP_PLUGIN_URL."/".PLUGIN_BASE_DIRECTORY."/AppStore.php?appid=".$id;
$appList .= '<li class="store">
<a class="noeffect" href="'.$afflink.'" rel="nofollow" target="_blank">
<span class="rank">'.$count.'.</span>
<img class="image" src=\''.$image.'\'></img>
<span class="comment">'.$sellerName.'</span>
<span class="name">'.$title.'</span>
<span class="comment">'.$price.' '.$label.'</span>
</a>
</li>';
if ($count==$topCount){
break;
}
$count=0;
foreach($doc->getElementsByTagName('entry')作为$node){
$count=$count+1;
$title=htmlspecialchars($node->getElementsByTagName('name')->item(0)->nodeValue);
$id=ExtractID(utf8_encode($node->getElementsByTagName('id')->item(0)->nodeValue));
$price=htmlspecialchars($node->getElementsByTagName('price')->item(0)->nodeValue);
$sellerName=htmlspecialchars(($node->getElementsByTagName('Artister')->item(0)->nodeValue));
$image=utf8_encode($node->getElementsByTagName('image')->item(0)->nodeValue);
$afflink=WP_PLUGIN_URL./”.PLUGIN_BASE_DIRECTORY./AppStore.php?appid=“.id;
$appList.='
';
如果($count==$topCount){
打破
}
我尝试添加getAttribute('label'),但我就是无法让它工作。我很想只在foreach循环中添加一行。我认为解决方案非常简单,但在尝试和搜索web数小时后我无法获得它:(解决了它
foreach ($node->getElementsByTagName('category') as $node) {
$label = $node->getAttribute('label');
}
我想到了类似的东西,但不幸的是它不起作用:$category=htmlspecialchars($node->getElementsByTagName('category')->item(0)->getAttribute('label')->nodeValue);