I
I
Ivan Kolchev2016-10-15 18:54:26
C++ / C#
Ivan Kolchev, 2016-10-15 18:54:26

How to select an xml node by the value of another?

Working with xml

<data>
<item>
<id>182</id>
<art_url/>
<artist>Kevin Griffiths</artist>
<channel_id>182</channel_id>
<display_artist>Kevin Griffiths</display_artist>
<display_title>Cantona Kung Fu (Original Mix)</display_title>
<duration>425</duration>
<http://www.cyberforum.ru/images/>
<length>425</length>
<network_id>1</network_id>
<release/>
<started>1476543203</started>
<title>Cantona Kung Fu (Original Mix)</title>
<track>Kevin Griffiths - Cantona Kung Fu (Original Mix)</track>
<track_id>992885</track_id>
<type>track</type>
</item>
<item>
<id>67</id>
<art_url>
//static.audioaddict.com/d/d/2/1/a/b/dd21ab7deb18a4b5a00e68601c4dafa2.jpg
</art_url>
<artist>Sygnals</artist>
<channel_id>67</channel_id>
<display_artist>Sygnals</display_artist>
<display_title>Thymisis</display_title>
<duration>529</duration>
<images>
<default>
//cdn-images.audioaddict.com/d/d/2/1/a/b/dd21ab7deb18a4b5a00e68601c4dafa2.jpg{?size,height,width,quality,pad}
</default>
</images>
<length>529</length>
<network_id>1</network_id>
<release>Superluminal</release>
<started>1476542890</started>
<title>Thymisis</title>
<track>Sygnals - Thymisis</track>
<track_id>713905</track_id>
<type>track</type>
</item>

I have the value of the id tag in the program, I need to get the value of the artist tag from the same item, in which the given value of the id tag.
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
JackBoner, 2016-10-15
@JackBoner

//item[id/text()=182]/artist

S
spancode, 2016-10-16
@spencode

This can be done using XPath selectors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question