I'm trying to Query information from an xmltv document using xmllint inside of a bash script and I'm having trouble with program titles that have single quotes in the title. For example:
XML Example:
<programme start="20150106090000 -0500" stop="20150106093000 -0500" channel="I53.28457646.microsoft.com">
<title lang="en">Daniel Tiger's Neighborhood</title>
<sub-title lang="en">Safety Patrol; Safety at the Beach</sub-title>
<desc lang="en">Prince Tuesday visits the school in his crossing guard uniform and helps the children practice safety rules; Daniel and Katerina drift too far from Mom while playing at the beach.</desc>
<credits>
<actor>Jake Beale</actor>
<actor>Ted Dykstra</actor>
<actor>Heather Bambrick</actor>
<actor>Amariah Faulkner</actor>
<actor>Stuart Ralston</actor>
<actor>Zachary Bloch</actor>
<actor>Addison Holley</actor>
<actor>Nicholas Kaegi</actor>
</credits>
<date>20130715</date>
<category lang="en">Children</category>
<category lang="en">Educational</category>
<category lang="en">Episodic</category>
<category lang="en">Kids</category>
<category lang="en">Series</category>
<episode-num system="onscreen">130</episode-num>
<episode-num system="ms_progid">1.EP015507510029</episode-num>
<episode-num system="dd_progid">EP01550751.0029</episode-num>
<video>
<aspect>16:9</aspect>
<quality>HDTV</quality>
</video>
<audio>
<stereo>stereo</stereo>
</audio>
<previously-shown start="20130715000000" />
<subtitles type="teletext" />
<rating system="VCHIP">
<value>TV-Y</value>
</rating>
</programme>
xmllint line:
xmllint --xpath '/tv/programme[title='Daniel Tiger's Neighborhood']' xmltv.xml
I've tried several options to try an escape it including wrapping in double quotes and writing Tiger''s and Tiger's and nothing I try seems to help.
Any help is appreciated. Thanks!
"/tv/programme[title='Daniel Tiger's Neighborhood']"should work from the shell's perspective but that isn't going to help the internal problem."/tv/programme[title=\"Daniel Tiger's Neighborhood\"]"might work so might"/tv/programme[title='Daniel Tiger\'s Neighborhood']"but it depends on xmllint and xml quoting.