Cedric
Cedric

Reputation: 453

Extracting data from RDF in php?

I'm a bit lost. I'd like to extract specific parts of rdf files to build sql tables with.

Here's the start of the rdf file:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xml:base="http://rdf.insee.fr/geo/2011/"
    xmlns:geo="http://rdf.insee.fr/geo/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

    <rdf:Description rdf:about="http://rdf.insee.fr/geo/2011/cantons-31-2011.rdf">
        <dc:title xml:lang="fr">Cantons et communes du département de la Haute-Garonne (31)</dc:title>
        <dc:date>2011-02-21</dc:date>
        <dc:publisher>INSEE</dc:publisher>
        <dc:format>XML-RDF</dc:format>
    </rdf:Description>

    <geo:Canton rdf:about="CAN_3101">
        <geo:code_canton>3101</geo:code_canton>
        <geo:nom xml:lang="fr">Aspet</geo:nom>
        <geo:chef-lieu rdf:resource="COM_31020"/>
        <geo:subdivision>
            <geo:Commune rdf:about="COM_31011">
                <geo:code_commune>31011</geo:code_commune>
                <geo:nom xml:lang="fr">Arbas</geo:nom>
                <geo:voisin rdf:resource="COM_31011" />
                <geo:voisin rdf:resource="COM_31140" />
                <geo:voisin rdf:resource="COM_31191" />
                <geo:voisin rdf:resource="COM_31236" />
                <geo:voisin rdf:resource="COM_31357" />
            </geo:Commune>
        </geo:subdivision>

I'd like to extract each geo:code_canton with it's geo:nom xml:lang="fr" to put them in s table. Then extract geo:code_commune and it's geo:nom xml:lang="fr"to put them in another table with the geo:code_canton

I need them to reference each canton and every city in that canton.

Any help or hint ?

Thanks

Upvotes: 1

Views: 1409

Answers (1)

Cedric
Cedric

Reputation: 453

Gone with www.aelius.com/njh/easyrdf/

Upvotes: 3

Related Questions