xmlstarlet sel表数据
我正试图从以下xml代码片段中检索表行。指向代码段的路径是xmlstarlet sel表数据,xml,xml-parsing,xmlstarlet,Xml,Xml Parsing,Xmlstarlet,我正试图从以下xml代码片段中检索表行。指向代码段的路径是//html/body/div/div/div。我需要选择/table/tr/th/a@title=“音乐流派” 我可以选择tr行作为: xmlstarlet sel -t -v "//html/body/div/div/div/table/tr/th/a[@title='Music genre']" Unwritten_Law 我可以选择以下数据行: xmlstarlet sel -t -v "//html/body/div/div/
//html/body/div/div/div
。我需要选择/table/tr/th/a@title=“音乐流派”
我可以选择tr行作为:
xmlstarlet sel -t -v "//html/body/div/div/div/table/tr/th/a[@title='Music genre']" Unwritten_Law
我可以选择以下数据行:
xmlstarlet sel -t -v "//html/body/div/div/div/table/tr/td/a" Unwritten_Law
我需要做的是只选择tr行是音乐类型的数据行
<table class="infobox vcard plainlist" style="border-spacing:3px;width:22em">
<tr>
<th colspan="2" style="text-align:center;font-size:125%;font-weight:bold;background-color: #b0c4de"><span class="fn org">Unwritten Law</span></th>
</tr>
<tr>
<th scope="row" style="text-align:left">Origin</th>
<td><a href="/wiki/San_Diego,_California" title="San Diego, California" class="mw-redirect">San Diego, California</a>, U.S.</td>
</tr>
<tr>
<th scope="row" style="text-align:left"><a href="/wiki/Music_genre" title="Music genre">Genres</a></th>
<td><a href="/wiki/Pop_punk" title="Pop punk">Pop punk</a>, <a href="/wiki/Punk_rock" title="Punk rock">Punk rock</a>, <a href="/wiki/Skate_punk" title="Skate punk">Skate punk</a>, <a href="/wiki/Post_grunge" title="Post grunge" class="mw-redirect">Post grunge</a>, <a href="/wiki/Alternative_rock" title="Alternative rock">Alternative rock</a>, <a href="/wiki/Melodic_hardcore" title="Melodic hardcore">Melodic hardcore</a></td>
</tr>
<tr>
<th scope="row" style="text-align:left">Years active</th>
<td>1990–present</td>
</tr>
</table>
不成文法
起源
,美国。
, , ,
活跃年份
1990年至今
给出问题中的片段:
xmlstarlet sel -t -v "/table/tr[th/a/@title='Music genre']/td/a" Unwritten_Law
输出
Pop punk, Punk rock, Skate punk, Post grunge, Alternative rock, Melodic hardcore
根据需要添加/html/body/div/div/div