# Parsing RDF coming from a URL

**URL:** <https://www.ruby-forum.com/t/parsing-rdf-coming-from-a-url/53315>\
**Category:** Rails\
**Created:** [February 1, 2006, 3:56pm UTC](https://www.ruby-forum.com/t/parsing-rdf-coming-from-a-url/53315 "2006-02-01T15:56:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Werner\_Ramaekers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/57b2e6/32.png) [@Werner\_Ramaekers](https://www.ruby-forum.com/u/Werner_Ramaekers)\
**Post date:** [February 1, 2006, 3:56pm UTC](https://www.ruby-forum.com/t/parsing-rdf-coming-from-a-url/53315/1 "2006-02-01T15:56:44Z")

</div>

Hello,

i’m writing an application that needs geocoding information for  
locations  
outside of the US.  
I’m using the [brainoff.com](http://brainoff.com) geocoding service

mappoint = Net::HTTP.new(‘[brainoff.com](http://brainoff.com)’, 80)  
response = mappoint.get(‘/geocoder/rest/?city=Gent,BE’)  
logger.debug response.body

and the body of the response is in the following form :

\<rdf:RDF xmlns:geo=“[http://www.w3.org/2003/01/geo/wgs84\_pos#](http://www.w3.org/2003/01/geo/wgs84_pos#)”  
xmlns:rdf="  
[http://www.w3.org/1999/02/22-rdf-syntax-ns#](http://www.w3.org/1999/02/22-rdf-syntax-ns#)"\>  
geo:Point  
geo:long3.7166667\</geo:long\>  
geo:lat51.05\</geo:lat\>  
\</geo:Point\>  
\</rdf:RDF\>

Now my question is : how do i parse this RDF to get to the long and lat  
values ?  
Is there a library available or am i on my own to get to the long and  
lat  
values ?

thanks for your help

Werner

## –

ir. Werner Ramaekers

Read my Blog at [http://www.werner.be](http://www.werner.be)  
“May the source be with you.”

---

<div class="post-metadata">

**Author:** ![Werner\_Ramaekers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/57b2e6/32.png) [@Werner\_Ramaekers](https://www.ruby-forum.com/u/Werner_Ramaekers)\
**Post date:** [February 1, 2006, 5:48pm UTC](https://www.ruby-forum.com/t/parsing-rdf-coming-from-a-url/53315/2 "2006-02-01T17:48:30Z")

</div>

Technically that’s RDF/XML, and you should be able to parse it with any  
of  
Ruby’s XML libraries - REXML, XMLParser, libxml, etc. REXML is part of  
the  
standard Ruby distribution.

---

<div class="post-metadata">

**Author:** ![Werner\_Ramaekers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/57b2e6/32.png) [@Werner\_Ramaekers](https://www.ruby-forum.com/u/Werner_Ramaekers)\
**Post date:** [February 1, 2006, 6:30pm UTC](https://www.ruby-forum.com/t/parsing-rdf-coming-from-a-url/53315/3 "2006-02-01T18:30:47Z")

</div>

You could also take a look at Ruby integration with Redland if you want  
to  
do any Sparql related stuff with your RDF:  
[http://librdf.org/docs/ruby.html](http://librdf.org/docs/ruby.html)

Here is a good article if you are new to Sparql/Semantic Web with RDF as  
the  
underpinnings:  
[http://www.xml.com/pub/a/2005/11/16/introducing-sparql-querying-semantic-web-tutorial.html](http://www.xml.com/pub/a/2005/11/16/introducing-sparql-querying-semantic-web-tutorial.html)

---

<div class="post-metadata">

**Author:** ![Werner\_Ramaekers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/57b2e6/32.png) [@Werner\_Ramaekers](https://www.ruby-forum.com/u/Werner_Ramaekers)\
**Post date:** [February 2, 2006, 4:54pm UTC](https://www.ruby-forum.com/t/parsing-rdf-coming-from-a-url/53315/4 "2006-02-02T16:54:46Z")

</div>

There is also Rena[1] and Semitar[2]

[1] [http://raa.ruby-lang.org/project/rena/](http://raa.ruby-lang.org/project/rena/)  
[2] [http://semitar.projects.semwebcentral.org/](http://semitar.projects.semwebcentral.org/)

I don’t recommend using just an XML parser for ingesting RDF. That’s  
sorta like using regex to parse HTML. It’s really better to deal  
with it as the graph model it is. Sure, it could be done solely with  
an XML parser in this simplistic case, and maybe that is  
pragmatically a fine way to go. I’ve often parsed HTML with regex  
too 🙂

```
Erik

```
