Menu

Grab siblings from RSS feed?

Help
Gilles
2024-03-26
2024-03-26
  • Gilles

    Gilles - 2024-03-26

    Hello,

    I assume it can be done with XmlStarlet but it requires XPath kung-fu way above my head.

    I need to grab an RSS feed using wget, and then feed it to XmlStarlet to grab a few sibings from each item:

    wget -qO - https://feeds.acme.com/feed/rss.xml |xmlstarlet\xml.exe sel -t <magic here=""></magic>

    ===========
    rss/channel/item
    THIS rss/channel/item/title
    THIS rss/channel/item/guid
    rss/channel/item/guid/@isPermaLink
    rss/channel/item/description
    rss/channel/item/content:encoded
    THIS rss/channel/item/pubDate
    rss/channel/item/enclosure
    THIS rss/channel/item/enclosure/@url
    ===========

    Would someone have code handy I could use?

    Thank you.

     
  • Gilles

    Gilles - 2024-03-26

    For others' benefit…

    After diving into Andrew Watt's "XPath Essentials" from 2002, seasoned with a bit of googling, here's the solution:

    xml.exe sel -B -t -m "//item" -v "title" -n -v "guid" -n -v "enclosure/@url" -n -n test.xml

     

Log in to post a comment.