Right, I think, from piecing together the clues from all the other posts I have worked out what you want to do. You want to add a new <LIST /> with the next values of NICKID and ROWID so you need to find the greatest existing values. This then should do it:
use XML::XPath;
my $file = 'memlist.xml';
my $xp = XML::XPath->new(filename=>$file);
my $nodeset = $xp->find('/MEMBERLIST/LIST');
+
my $max_nickid = -1;
my $max_rowid = -1;
+
foreach my $list ( $nodeset->get_nodelist)
{
my $nickid = $list->findvalue('NICKID/text()')->value();
my $rowid = $list->findvalue('ROWID/text()')->value();
+
$max_nickid = $nickid if ($nickid > $max_nickid);
$max_rowid = $rowid if ($rowid > $max_rowid);
}
+
print "NICK: $max_nickid ROWID: $max_rowid\n";
On a more general note I think you might be better served if you explain what it is you are trying to do in a wider sense in future as you seem to be posting lots of little questions dealing with a very small part of your larger problem which makes it difficult for people to help you, it also seems to indicate that you don't have a clear design of what you are trying to achieve when you start out, explaining the bigger picture to us will almost certainly help you get a view of what you are trying to achieve as well as making it possible for us to make suggestions as to how to achieve what you want rather than nibbling away at the problem.
/J\ |