Hi Fred, I wrote a PHP SRU client that might help you out:
It's, uh, underdocumented (looking at it now), but I'll work on that when I'm back to a consistent internet connection.
Even if you don't want the whole library, it might give you some pointers for parsing the response.
On Tuesday, August 19, 2014, Jonathan Rochkind <[log in to unmask]
I am not familiar with PHP XML processing routines, but in other languages, I actually find it most convenient to simply remove the namespaces from the XML before trying to deal with the XML.
Yes, heretical. Yes, it could be a problem if the document contains two different elements with the same name but different namespace in a way that conflicts (I've NEVER actually run into that problem).
But so many XML libraries make it so hard to deal with namespaces (and often have bugs with it), I often find it most convenient to just remove em and have a namespace-less document.
Of course, whether you can do THAT (remove namespaces) conveniently may depend on your XML processing library too. Sorry, not familiar with how this is done in PHP.
On 8/19/14 11:41 AM, Fred Riley wrote:
Thanks, Mike, and to Jörg for his offline reply. You're right, the XML
returned from the SRU query is valid. My problem, with which I've
grappled with the help of Monica Duke (whom you'll know of) despite her
being on maternity leave, is traversing the hierarchy of children in a
multi-namespace document to get at the info I need. So, in the example I
the returned XML has nested namespaces, and I was trying to get hold of
record fields (eg title, description) by traversing the hierarchy of
children, but got stuck amongst eye-scrunching XML and PHP code. I put
some test scripts online
were my early and failed efforts to do this some weeks back. I'm hoping
that returning now with a fresh mind, and picking brains on this list,
will lead to a fresh approach.
I'm off on leave for two days so won't be on this until Friday, when
I'll give Jörg's code a bash.
(If you're getting /déja vu/, Mike, it's because I posted a precursor to
this query to cetis-metadata on 12th June, and you and Monica
contributed to the thread. )
*From:*SRU (Search and Retrieve Via URL) Implementors
[mailto:[log in to unmask]] *On Behalf Of *Mike Taylor
*Sent:* 19 August 2014 13:41
*To:* [log in to unmask]
*Subject:* Re: SRU parsing with PHP
Fred, I think this forum is perfectly appropriate.
What exactly is it that you're having difficulty with? Looks to me like
you have a perfectly good XML document there. You can feed it to the XML
parser of your choice in PHP, and walk the resulting tree to extract the
information you need.
Do you have a more specific query?
On 19 August 2014 12:10, Fred Riley <[log in to unmask]
<mailto:[log in to unmask]>> wrote:
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
The query I want to post is related to, and descended from, a query
I posted to StackOverflow a while back
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:
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 :)