drryyiuib43562604 2011-05-20 16:11
浏览 46
已采纳

从Wordpress RSS提要获取每个帖子的标签

Given a Wordpress RSS feed, I would like to know how can I get all the tags for each post. As far as I can see, for each tag there's an entry like this <category><![CDATA[ ]]></category>. I'm using PHP's SimpleXmlElement.

Thank you.

  • 写回答

1条回答 默认 最新

  • douyong1905 2011-05-20 16:20
    关注

    You can use SimpleXMLElement::xpath to do this. So:

    <?php
    $x = new SimpleXMLElement($xml_for_one_item);
    $result = $x->xpath('category');
    foreach ($result as $cat) {
        // do something with the category string in $cat
    }
    ?>
    

    The only disadvantage here is you must pass the XML for only one item at a time. If you know which items you wish to use, change it to $x->channel->item[0]->xpath('.//category') for the first item, etc.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题