I've been looking recently over some of the XML capabilities of Drupal 6. There seems to be some extremely well handled RPC code.
But what seems to be missing is handling for the loads of non-standard XML out there.

The closest I saw drupal_xml_parser_create.
But, that doesn't cover the whole job. Nor does it handle hosting differences.

I've been working on a method to pull XML from a url into a standard array.
So far, it works using php's simplexml if the host allows it, or parsing the xml file with xml2array.
Either way, the exact same array is returned.

I can't believe I'm the first to want some standard handling for XML. I must have duplicated someone's work. Does anyone know of anything similar to what I've done? Should I need to offer it as a simple utility module?

Comments

dman’s picture

And what is it that's wrong with simplexml or xml2array?
You say that "I've been working on a method to pull XML from a url into a standard array." . Fair enough. It should be only a couple of lines, right? Assuming php5 - which we damn well better assume.

Where it gets tricky is beyond that, where you actually have some special need for parsing, or a way of looking at the data that doesn't fit the provided methods.
There's nothing wrong with rolling up a few utilities if you think it'll help, but usually I find the bits I need on the php.net doc comments.

lance.gliser’s picture

It's not that anything is wrong with them, at all.
I use them, love em. Need em for what I'm doing.

It's just that there needs to be a standard, that can be expected when an XML call is made, through any method.
The code for it is really only about 150ish (including xml2array) lines. I just think it's important everyone has that standard to rely on. I missed it when I was starting work on a project.

dman’s picture

I just don't quite understand the question. What is the 'standard' beyond XML itself?
We each have a few conventions that we are more comfortable with, but nowadays I use XPath and Nodesets more than I do indexed arrays from XML. I've seen a few cracks at 'simplifying' XML, but there's a few differences between whether someone thinks an 'attribute' is a 'value', or that namespaces are to be discarded etc.
I'm thinking that the XML is a baseline that everyone can interpret for their own needs. If you describe exactly what you want to do with it that's better than an indexed array of some sort, then there could be a utility library in there, but I'm not sure exactly what the win you are looking for looks like...