Let's try to parse and extract node from Yahoo Weather RSS.
URL is here http://weather.yahooapis.com/forecastrss?w=12602818&u=c
xmllint has to be used for this purpose.
Here is the node to extract:
<yweather:condition text="Partly Cloudy" code="30" temp="3" date="Fri, 16 Nov 2014 8:10 am AST" />
The problem
A naive xmllint --xpath "//yweather:condition" the_rss_file_from_yahoo
replied with an error:
XPath error : Undefined namespace prefix
xmlXPathEval: evaluation failed
XPath evaluation failure
It has to comes from the fact there's a namespace defined. But we're stuck here.
Is it possible to get this node with xmllint, on the command line? And if yes, how?
Edit/Answer:
As the question was marked duplicated, if you're a XPath newbie like me looking for a one-liner solution, you may use xmllint filename --xpath "//*[local-name()='condition']"
, with two slashes contrarily to the other question, which was using one (because it was accessing the root node). However for the formal way to address this, see answer A) from the original question and use // instead of / in the XPath query (Thanks Tomalek for helping me out).