I am trying to populate nodes by writing a script...i am using following code
$node->field_tags['und'][0]['textfield'] = 'first_tag';
$node->field_tags['und'][0]['textarea'] = 'This is tag';
$node->field_tags['und'][0]['tid'] = 2;
node_save($node);
whatsits doing is nothing and the term is not being added to vocabulary named tag...if i write the following code it will select the already existed term call xml..i guess because of tid=1;
$node->field_tags['und'][0]['textfield'] = 'first_tag';
$node->field_tags['und'][0]['textarea'] = 'This is tag';
$node->field_tags['und'][0]['tid'] = 2;
node_save($node);
i even tried the following code
$node->field_tags['und'][0]['name'] = 'first_tag';
$node->field_tags['und'][0]['description'] = 'This is tag';
$node->field_tags['und'][0]['tid'] = 2;
node_save($node);
can someone please help me how add terms into a already existed vocabulary