使用XPath-5查询XML数据存储区

时间:2017-07-02 18:48:06

标签: xpath

假设您已经提供了XML片段,如下所示。你的任务是编写XPath选择器来拾取名为'变形金刚'的电影的架子。



<collection shelf="Classics">
<movie title="The Enemy" shelf="A">
   <type>War, Thriller</type>
   <format>DVD</format>
   <year>2001</year>
   <rating>PG</rating>
   <popularity>10</popularity>
   <description>Talk about a war</description>
</movie>
<movie title="Transformers" shelf="B">
   <type>Science Fiction</type>
   <format>DVD</format>
   <year>1980</year>
   <rating>R</rating>
   <popularity>7</popularity>
   <description>Science Fiction</description>
</movie>
   <movie title="Trigun" shelf="B">
   <type>Action</type>
   <format>DVD</format>
   <episodes>4</episodes>
   <rating>PG</rating>
   <popularity>10</popularity>
   <description>Quite a bit of action!</description>
</movie>
<movie title="Ishtar" shelf="A">
   <type>Comedy</type>
   <format>VHS</format>
   <rating>PG</rating>
   <popularity>2</popularity>
   <description>Boring</description>
</movie>
</collection>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

假设标题没有备用空格试试这个

//movie[@title='Transformers']/@shelf