我正在尝试在bash脚本中使用xmllint从xmltv文档中查询信息,并且遇到标题中带有单引号的程序标题时遇到问题。例如:
XML示例:
<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行:
xmllint --xpath '/tv/programme[title='Daniel Tiger's Neighborhood']' xmltv.xml
我尝试了几种方法来尝试逃脱它,包括用双引号引起来并编写Tiger's和Tiger
'
,但我尝试的任何方法似乎都无济于事。任何帮助表示赞赏。谢谢!
最佳答案
感谢@EtanReisner这行得通!:
xmllint --xpath "/tv/programme[title=\"Daniel Tiger's Neighborhood\"]" xmltv.xml
关于xml - 在Bash脚本中转义单引号xmllint xpath查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27926883/