我試圖從xmltv文檔中使用bash腳本內部的xmllint查詢信息,並且遇到標題中帶有單引號的程序標題的問題。例如:在bash腳本中轉義單引號xmllint xpath查詢
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
我試過幾個選項來嘗試一種逃避它包括包裹在雙引號,寫老虎 '' s和老虎'
s沒有我嘗試似乎幫助。
任何幫助表示讚賞。謝謝!
你從標籤計劃需要哪些信息,標題爲「丹尼爾老虎的鄰居」? – Cyrus
使用''/ tv/program [title ='丹尼爾虎的鄰居']「應該從shell的角度來看,但這不會幫助解決內部問題。 ''/ tv/program [title = \「Daniel Tiger's Neighbourhood \」]「'可能會這樣''/ tv/program [title ='丹尼爾老虎的鄰居']」'但它取決於xmllint和xml引用。 –
@Cyrus最後的遊戲是在前面顯示的標籤中獲取start =「」屬性的內容,以使用節目標題,描述和開始時間作爲我的匹配標準來獲取原始播出日期。通過這種方式,我可以用Plex Media Server的原始日期來命名錄音,以提取並查詢TheTVDB.com信息。 – AndyRBlank