tags:

views:

58

answers:

2

How can I use Xpath to only select the all dict's that contain genre?

    <dict>
  <key>genre</key><string>News</string>
  <key>genreId</key><integer>6009</integer> 
</dict>

<dict>
  <key>fieldID</key><integer>2</integer>
</dict>
+2  A: 

Before your edit:

You can use the function position()

//dict[ position() = 1 ]

or short version

//dict[ 1 ]

After your edit:

//dict[key = 'genre']

returns all dict elements which have the element key equal to 'genre'

Gaim
I've never heard of a `first()` function (and, frankly, I can't imagine there is one) - do you have a link to the documentation for me?
Tomalak
Ok my fault. I changed it with `last()`. I fixed my answer
Gaim
+2  A: 

Try this:

//dict[key = 'genre']
Rubens Farias