http://www.perlmonks.org?node_id=1012420


in reply to XML::Simple - Handling inconsistency

You appear to be trying to parse SPARQL result sets. There are some really good RDF/SPARQL modules for Perl, so you needn't be mucking around with XML stuff!

use strict; use warnings; use RDF::Query::Client; my $query = RDF::Query::Client->new(<<'SPARQL'); PREFIX category: <http://dbpedia.org/resource/Category:> PREFIX dc: <http://purl.org/dc/terms/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT * WHERE { ?resource dc:subject category:English_film_actors . ?resource dc:subject category:Life_peers . ?resource rdfs:label ?name . FILTER ( langMatches(lang(?name), "en") ) } SPARQL my $results = $query->execute('http://dbpedia.org/sparql'); while (my $row = $results->next) { printf( "%s <%s>\n", $row->{name}->literal_value, $row->{resource}->uri, ); }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'