Best way to parse XML for Drupal site to Drupal site communications with services module

Events happening in the community are now at Drupal community events on www.drupal.org.
shrop's picture

I am using the services module to setup a web service on one Drupal site and then have another Drupal site pull in the resultant xml data formatted for display. I am specifically using views.getView from the Services module xml-rpc server. It works great so far, but now I am wondering the best method for parsing the XML on the client end Drupal site.

Should I just use simplexml included with PHP and create a node with the PHP parsing code. Seems like there is a need for an XML-RPC client module, but I haven't found an existing project.

Any suggestion on how to parse the XML in a Drupal site and/or example code will be greatly appreciated.

Thanks!
Shrop

Comments

Already there

gdd's picture

Drupal actually includes an xmlrpc client in core.

http://api.drupal.org/api/function/xmlrpc/6

It works really well.

Beyond that, I always just use SimpleXML to parse results, although it should be noted that you're then making PHP 5 requirement, whereas Drupal 6 only requires PHP 4. This is becoming pretty common (a lot of contrib modules for 6 now require PHP 5 for this very reason) but its still worth mentioning.

Thanks for everyone's

shrop's picture

Thanks for everyone's suggestions. Great community around the services group here. I plan to spend some time here as I am doing a lot of web service integration with other systems on campus and Drupal at www.uncc.edu.

  1. I built a simple module to connect to the services xmlrpc endpoint on the source Drupal site. I think it will work well for this instance.
  2. I tried FeedAPI and had this issue: http://drupal.org/node/282180. It looks like a great module, but had to move on to get things working for now.
  3. Feed Element Mapper looks very cool BTW.
  4. I could stick with RSS for views if I have an aggregator/RSS client in Drupal that will do what I need. So far XMLRPC or Rest is easier and expandable for what I am doing.

Thanks all!
Shrop

Try FeedAPI

bmcmurray's picture

You should take a look at FeedAPI (http://drupal.org/project/feedapi).

Now, if you are just trying to remote data from a View, you could probably avoid Services completely and just have your View provide an RSS feed.

B.McMurray

B.McMurray

Dont forget the FeedAPI Element Mapper!

alex ua's picture

In order to really utilize the mojo of FeedAPI, you really need to pair it with the great module FeedAPI Element Mapper.

Alex Urevick-Ackelsberg
ZivTech: Illuminating Technology

Alex Urevick-Ackelsberg
ZivTech: Illuminating Technology

SOAP Server & Client

sukh.singh's picture

Hello to all drupal developers. Firstly thumbs up for creating such a nice module. It is a great module with less documentation for example I am not able to find single help for creating Webservice as SOAP Client and SOAP Server. It is really a need for today scenario. If anybody know the link or have some knowledge please put all together here so that everybody can have access to that.

Sukh Singh

From my experience

emptyvoid's picture

Perhaps I will be labeled a Heretic now, but after several months of analysis on a HUGE project I determined that the services modules were too heavy handed to meet my client's syndication needs. Instead we built several custom modules and used, cck, views, and path-auto to accomplish the task.

We built a set of custom client modules as a development framework for create new feed types. Then we created a dedicated sub-site for syndication that utilized, cck, views, path-auto, and custom modules that extended views to create XML streams that handled multiple arguments.

One key library I used (attached) would parse the XML stream and turn it into a multi-dimensional array for use within my theme templates used to render the output on each sub-site and theme. Perhaps it will be useful for you, I found it invaluable in converting the XML structure and passing it on to my preprocessor functions for the theme templates.

The client was http://www.pdx.edu
and you can view the result here:

http://www.pdx.edu/events/
http://www.pdx.edu/news/
http://www.pdx.edu/faqs/
http://www.pdx.edu/profile/

Robert Foley Jr
Solutions Architect
http://www.robertfoleyjr.com

I am trying with XPath

jacksonkirka's picture

The queries work logically. It could be permissions.

But it wont update a story when a feed is added.

Chow

What about

Parse XML in drupal

dianacastillo's picture

use the services module see: http://drupal.org/node/1851202

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: