I'm building a module and I need to get XML content over HTTP request.
The idea is to create nodes programmatically with the retrieved data from the xml file.
Can I do this?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI'm building a module and I need to get XML content over HTTP request.
The idea is to create nodes programmatically with the retrieved data from the xml file.
Can I do this?
Its a little bit of a learning curve , but I would recommend using the feeds module for this
https://www.drupal.org/project/feeds
you can then load xml (or csv) to nodes, and map its contents to nodes. This is preferable to writing your own custom functionality.
but if you do, drupal_http_request(), and then node_save() for constructing the nodes would be the way to do things. If you do code it yourself, Id recommend getting comfortable with running scripts with drush, as that'll be easier than battling timeouts in the browser
drupal_http_request()
?$url
) parameter:$request = drupal_http_request('http://domain.com/xml_file.xml');
. The XML file would be in$results->data
.