I am working on a project to import XML contents into Drupal 7. I have parsed all the data in PHP.
So far i have succeeded in importing the node body and its title. There is no documentation for Drupal 7 on how to attach an image to the node and tags. I really need help, as I have spent two days trying to find a solution. I will be very grateful if anyone comes up with a solution. Please just guide me somewhere.
function make_nodes($nodes) {
$new_node = $nodes[0];
$node = new stdClass();
$node->title = $new_node['title'];
$node->body['und'][0]['value'] = $new_node['body'];
$node->type = 'article';
$node->created = $new_node['timestamp'];
$node->changed = $new_node['timestamp'];
$node->status = 1;
$node->promote = 1;
$node->sticky = 0;
$node->body['und'][0]['format'] = 1;
$node->uid = (isset($local_user->uid) && !empty($local_user->uid)?$local_user->uid:1);
$node->language = 'en';
$node->timestamp = $new_node['timestamp'];
$node->revision = 0;
node_submit($node);
node_save($node);
}