# XML parsing/mapping?

**URL:** <https://www.ruby-forum.com/t/xml-parsing-mapping/191777>\
**Category:** Rails\
**Created:** [July 18, 2010, 2:08pm UTC](https://www.ruby-forum.com/t/xml-parsing-mapping/191777 "2010-07-18T14:08:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lasse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/96bed5/32.png) [@Lasse](https://www.ruby-forum.com/u/Lasse)\
**Post date:** [July 18, 2010, 2:08pm UTC](https://www.ruby-forum.com/t/xml-parsing-mapping/191777/1 "2010-07-18T14:08:07Z")

</div>

I have a problem parsing/mapping a xml response from a API.

I would like to get the id numer of a keyword when the keyword.text is  
like ‘Engels’

So i would like search in the xml response for the text ‘Engels’ than  
i would like to have the ‘href’ that belongs to that keyword. In this  
case [http://www.wrts.nl/api/keywords/84576](http://www.wrts.nl/api/keywords/84576), i actually only need the  
id numer because than i can make a new request to the api with that  
information.

The xml-response looks like this:

\<?xml version=\"1.0\" encoding=\"UTF-8\"?\>\n\n

\<keyword href="[http://www.wrts.nl/api/keywords/83212\](http://www.wrts.nl/api/keywords/83212%5C)“\>Duits  
\n  
\<keyword href="[http://www.wrts.nl/api/keywords/84576\](http://www.wrts.nl/api/keywords/84576%5C)”\>Engels\</  
keyword\>\n  
\<keyword href="[http://www.wrts.nl/api/keywords/84562\](http://www.wrts.nl/api/keywords/84562%5C)“\>Franconville\</  
keyword\>\n  
\<keyword href="[http://www.wrts.nl/api/keywords/83711\](http://www.wrts.nl/api/keywords/83711%5C)”\>Frans  
\n  
\<keyword href="[http://www.wrts.nl/api/keywords/108275\](http://www.wrts.nl/api/keywords/108275%5C)“\>FRvmbo1ldt\</  
keyword\>\n  
\<keyword href="[http://www.wrts.nl/api/keywords/85763\](http://www.wrts.nl/api/keywords/85763%5C)”\>Groep 4\</  
keyword\>\n  
\<keyword href="[http://www.wrts.nl/api/keywords/84571\](http://www.wrts.nl/api/keywords/84571%5C)“\>Kapitel 1\</  
keyword\>\n  
\<keyword href="[http://www.wrts.nl/api/keywords/83213\](http://www.wrts.nl/api/keywords/83213%5C)”\>klas 2\</  
keyword\>\n  
\<keyword href="[http://www.wrts.nl/api/keywords/84563\](http://www.wrts.nl/api/keywords/84563%5C)“\>Leerjaar 1\</  
keyword\>\n  
\<keyword href="[http://www.wrts.nl/api/keywords/84570\](http://www.wrts.nl/api/keywords/84570%5C)”\>leerjaar 1 h/  
v\n  
\<keyword href="[http://www.wrts.nl/api/keywords/84572\](http://www.wrts.nl/api/keywords/84572%5C)“\>Lektion 1\</  
keyword\>\n  
\<keyword href="[http://www.wrts.nl/api/keywords/83725\](http://www.wrts.nl/api/keywords/83725%5C)”\>Uitgever\</  
keyword\>\n  
\<keyword href="[http://www.wrts.nl/api/keywords/84578\](http://www.wrts.nl/api/keywords/84578%5C)“\>unit 1\</  
keyword\>\n  
\<keyword href="[http://www.wrts.nl/api/keywords/84564\](http://www.wrts.nl/api/keywords/84564%5C)”\>Unit\xC3\xA9  
1\n  
\<keyword href="[http://www.wrts.nl/api/keywords/85762\](http://www.wrts.nl/api/keywords/85762%5C)“\>Woordpakket  
1a\n  
\n”

How should i do this? Do i need to parse the xml first, or is there a  
way to search in the xml directly?

Thank you in advance,  
Regards Lasse
