Hi Fred,
this is a PHP XML issue, not much SRU implementation related - although
off-topic, I allow myself to give some hints.
Maybe you should take a closer look at PHP "SimpleXML"
http://php.net/manual/en/book.simplexml.php
You have to iterate by namespace over the children, like this
<?php
$content =
file_get_contents('http://explor.bcu.ac.uk/IntraLibrary-SRU?operation=searchRetrieve&query=gaelic&version=1.1');
$xml = simplexml_load_string($content);
$namespaces = $xml->getNameSpaces(true);
$children = $xml->children($namespaces['SRW']);
print_r($children);
?>
The 'dc' namespace can be iterated within the records.
In Perl, XML processing from SRU is really simple, like this
use strict;
use warnings;
use Data::Dumper;
use LWP::Simple;
use XML::Simple;
my $content =
get("http://explor.bcu.ac.uk/IntraLibrary-SRU?operation=searchRetrieve&query=gaelic&version=1.1");
my $xs = XML::Simple->new();
my $ref = $xs->XMLin($content);
print Dumper $ref;
Best,
Jörg
>>> Fred Riley <[log in to unmask]> schrieb am 19.08.2014 um 13.10
Uhr in
Nachricht
<[log in to unmask]>:
> Hi
>
> This is my first message to this list, which I've only just joined at
the
> recommendation of a colleague. I'm looking to develop a website for
Open
> Educational Resources (OER), which will query SRU services in open
> repositories. I've been trying to write PHP scripts to query SRU
services,
> but running into the sand parsing the returned XML. My preliminary
question
> is: is this listserv an appropriate place to post technical queries
about
> SRU, or is more 'meta'?
>
> The query I want to post is related to, and descended from, a query I
posted
> to StackOverflow a while back
>
(http://stackoverflow.com/questions/24248429/simplest-way-to-parse-sru-xml).
The
> repository I'm wanting to query, in the first instance, is the
Intralibrary
> installation at my current institution (SRU service URL:
> http://explor.bcu.ac.uk/IntraLibrary-SRU). An example query I need to
parse
> the results of is:
>
>
http://explor.bcu.ac.uk/IntraLibrary-SRU?operation=searchRetrieve&query=gaelic&
> version=1.1
>
> If I can get SRU querying of this repository working then it'll be
> applicable to other repositories.
>
> As background, I have experience of learning object repository
> (Intralibrary) administration, and of learning object metadata
schemas
> (especially UK LOM Core) and applications. I'm also an experienced
PHP coder.
> I've done an awful lot of reading of fine manuals, fora and websites.
I have
> a half-decent understanding of XML but am no expert, and know nothing
at all
> about XPath and XSLT.
>
> Thanks in anticipation for your tolerance and help :)
>
> Fred
> www.fredriley.org.uk
--
Jörg Prante
hbz, Gruppe Portale
- Digitale Bibliothek und Online-Fernleihe -
Postfach 270451, 50510 Köln, Deutschland
Telefon +49-221-40075-156, Fax +49-221-40075-190
[log in to unmask]
http://www.hbz-nrw.de
|