For better or worse, this is the code I use in the aggregation module and it seems to be working flawlessly. This is in the yet to be released release though (drupal 5). If there&#39;s a better way I&#39;d be glad to know it.<br>
<br>(INSERT)<br>$node = new stdClass();<br>$node-&gt;title = &quot;{$XML-&gt;name}&quot;;<br>$node-&gt;body = &quot;{$XML-&gt;description}&quot;;<br>$node-&gt;eid = $eid;<br><br>node_save($node);<br>module_invoke_all(&#39;nodeapi&#39;, $node, &#39;insert&#39;, NULL, NULL);<br>
<br>--------------<br>(UPDATE)<br>$node = node_load(array(&#39;nid&#39; =&gt; 5));<br>$node-&gt;title = &quot;{$XML-&gt;name}&quot;;<br>
$node-&gt;body = &quot;{$XML-&gt;description}&quot;;<br>
$node-&gt;eid = $eid;<br><br>node_save($node);<br>module_invoke_all(&#39;nodeapi&#39;, $node, &#39;update&#39;, NULL, NULL);<br>
<br><br><div class="gmail_quote">On Sat, Mar 8, 2008 at 8:01 PM, Larry Garfield &lt;<a href="mailto:larry@garfieldtech.com">larry@garfieldtech.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Using drupal_execute() or drupal_execute_macro() is a nasty, evil, slow, and<br>
ugly way to programmatically create users and nodes. &nbsp;It&#39;s also usually the<br>
only way that will reliably work. :-) &nbsp;I have, however, run into cases where<br>
it does not. &nbsp;For those, I have to fall back to creating the $node object<br>
myself and saving it. &nbsp;Fortunately I&#39;ve only had to do that for one-off<br>
imports, so I could hard-code defaults.<br>
<br>
There is no real good answer here, not until we get a real Data API in core.<br>
We&#39;re working on it. :-)<br>
<div><div></div><div class="Wj3C7c"><br>
On Saturday 08 March 2008, Moshe Weitzman wrote:<br>
&gt; In drupal5, you should call hook_node_submit() and<br>
&gt; hook_nodeapi(&#39;submit&#39;) before node_save(). that will assure that any<br>
&gt; group info gets saved (for example).<br>
&gt;<br>
&gt; In d6 this is not needed since those submit hooks became<br>
&gt; hook_nodeapi(pre_save) and that happens from within node_save().<br>
&gt;<br>
&gt; drupal_execute is also a valid way. the node_load() is a little<br>
&gt; expensive but this is a very clean way to proceed. if it is working<br>
&gt; for you, i would proceed like this.<br>
&gt;<br>
&gt; On Sat, Mar 8, 2008 at 10:53 AM, Novák Áron &lt;<a href="mailto:aron@novaak.net">aron@novaak.net</a>&gt; wrote:<br>
&gt; &gt; Hi!<br>
&gt; &gt;<br>
&gt; &gt; &nbsp;While the development of FeedAPI, i faced with a problem. FeedAPI has to<br>
&gt; &gt; &nbsp;create nodes programmatically, i believed that this is a really easy<br>
&gt; &gt; thing to do, feedapi now works like this:<br>
&gt; &gt; &nbsp;$node-&gt;data1 = &quot;foo&quot;;<br>
&gt; &gt; &nbsp;$node-&gt;data2 = &quot;bar&quot;;<br>
&gt; &gt; &nbsp;node_object_prepare($node); // this is about the default values<br>
&gt; &gt; &nbsp;node_save($node);<br>
&gt; &gt;<br>
&gt; &gt; &nbsp;But I got a report that this is not a good way to do:<br>
&gt; &gt; &nbsp;<a href="http://drupal.org/node/196273" target="_blank">http://drupal.org/node/196273</a><br>
&gt; &gt; &nbsp;Summary:<br>
&gt; &gt; &nbsp;&quot;node_object_prepare() and node_prepare() functions are meant to<br>
&gt; &gt; simulate the demonstration of a node&quot;<br>
&gt; &gt; &nbsp;And some users, who use FeedAPI + 3rd party modules together, really<br>
&gt; &gt; &nbsp;experience bugs around node creation / handling:<br>
&gt; &gt; &nbsp;<a href="http://drupal.org/node/195105" target="_blank">http://drupal.org/node/195105</a> (summary: the core forum module uses<br>
&gt; &gt; form_alter to pass taxonomy-like data. And this data is lost now.)<br>
&gt; &gt;<br>
&gt; &gt; &nbsp;Can you suggest me a perfect way to handle this problem?<br>
&gt; &gt; &nbsp;mustafau (<a href="http://drupal.org/user/207559" target="_blank">http://drupal.org/user/207559</a>) suggested to use<br>
&gt; &gt; &nbsp;drupal_execute($form_id, $form_values), but in this case, i had another<br>
&gt; &gt; &nbsp;problem: drupal_execute has no useful return value and $node structure<br>
&gt; &gt; &nbsp;remains unaltered, so i had to do a node_load after this, which is quite<br>
&gt; &gt; &nbsp;expensive.<br>
&gt; &gt;<br>
&gt; &gt; &nbsp;Thanks,<br>
&gt; &gt;<br>
&gt; &gt; &nbsp;Aron Novak<br>
<br>
<br>
</div></div>--<br>
Larry Garfield &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AIM: LOLG42<br>
<a href="mailto:larry@garfieldtech.com">larry@garfieldtech.com</a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ICQ: 6817012<br>
<br>
&quot;If nature has made any one thing less susceptible than all others of<br>
exclusive property, it is the action of the thinking power called an idea,<br>
which an individual may exclusively possess as long as he keeps it to<br>
himself; but the moment it is divulged, it forces itself into the possession<br>
of every one, and the receiver cannot dispossess himself of it.&quot; &nbsp;-- Thomas<br>
Jefferson<br>
</blockquote></div><br><br clear="all"><br>-- <br>Ashraf Amayreh<br><a href="http://blogs.aamayreh.org">http://blogs.aamayreh.org</a>