1

我想从此 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="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>

我的 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;
            }

我尝试添加 getAttribute('label'),但我根本无法让它工作。我很想在 foreach 循环中添加一行。我认为解决方案非常简单,但是经过数小时的尝试和搜索后我无法得到它:(

4

1 回答 1

0

解决了!

        foreach ($node->getElementsByTagName('category') as $node) {
        $label = $node->getAttribute('label'); 
        }
于 2014-02-25T20:10:30.143 回答