Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8349709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:05:25+00:00 2026-06-09T08:05:25+00:00

I’ve never used xmlstarlet so I’m just going to keep it simple with input

  • 0

I’ve never used xmlstarlet so I’m just going to keep it simple with input and desired output, and hopefully I can learn something from the answers that are posted.

Input:

<channel>
    <title>
    <link>http://www.MYDOMAIN.com/</link>
    <description></description>
    <ttl>60</ttl>
    <category>Sports</category>

        <item>
             <sport><![CDATA[Women's Soccer]]></sport>
             <opponent><![CDATA[South Carolina (Exhibition)]]></opponent>
             <location><![CDATA[Columbia, S.C.]]></location>
             <date>08/09/2012</date>
             <time>7:00 PM</time>
             <tv><![CDATA[]]></tv>
             <tournamentname><![CDATA[]]></tournamentname>
             <homeaway>A</homeaway>
        </item>     

        <item>
             <sport><![CDATA[Men's Soccer]]></sport>
             <opponent><![CDATA[Ohio State (Exhibition)]]></opponent>
             <location><![CDATA[Fort Wayne, Ind.]]></location>
             <date>08/17/2012</date>
             <time>7:00 PM</time>
             <tv><![CDATA[]]></tv>
             <tournamentname><![CDATA[]]></tournamentname>
             <homeaway>H</homeaway>
        </item>     

        <item>
             <sport><![CDATA[Women's Soccer]]></sport>
             <opponent><![CDATA[William and Mary]]></opponent>
             <location><![CDATA[Williamsburg, Va.]]></location>
             <date>08/17/2012</date>
             <time>7:00 PM</time>
             <tv><![CDATA[]]></tv>
             <tournamentname><![CDATA[]]></tournamentname>
             <homeaway>A</homeaway>
        </item>

Desired output:

Women's Soccer Away @ South Carolina (Exhibition) at 7:00 PM
Men's Soccer Home vs Ohio State at 7:00 PM
Women's Soccer Away @ William and Mary at 7:00 PM

A few things that make this not just straightforward data manipulation

1) I’d like to remove all data that doesn’t have a <date> of the current date

2) As you can see from the desired output, I’d like for the A result of the element <homeaway> to show the text ‘Away @’ and I’d like for the H tag to show the text ‘Home vs’

Thanks so much for your help, I really appreciate it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:05:27+00:00Added an answer on June 9, 2026 at 8:05 am
    xmlstarlet sel --text -t \
        -m '//channel[category="Sports"]/item[date="'$(date +%m/%d/%Y)'"]' \
        -v sport -o ' ' \
        --if 'homeaway="H"' -o 'Home vs' --else -o 'Away @' -b -o ' ' \
        -v opponent -o ' ' \
        -o 'at ' -v time --nl \
        /tmp/rss.xml
    
    • -m (or –match) starts a foreach loop
    • -b (or –break) means endif (actually it’s a general endblock or closing brace)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.