in reply to Need help with XML::Twig, something strange is happening!!

Consider using the numerical comparison operators. You're dealing with numbers, so you shouldn't compare them as strings.

Try if ($ParentNodeId > 1) { instead of if ($ParentNodeId gt 1) {. Replace eq with ==.

While I'm here, can I suggest you use a hash for the input data, instead of that long list of variables? First define a list of field names:
my @field_names = qw/ ParentNodeId NodeId level canode label theme tem +plate /; # and so on for the rest
Then replace the split line with
my %attributes; @attributes{ @field_names } = split /,/, $line;
Then when you set the attributes on the XML::Twig::Elt, you can simply say:
$esec->set_att( %attributes );

Replies are listed 'Best First'.
Re^2: Need help with XML::Twig, something strange is happening!!
by stevee (Acolyte) on Mar 28, 2007 at 14:02 UTC
    Rhesa Thanks for the helpful suggestions. Replacing the operator has made no difference though I can see where you are coming from. The problem really lies in the XPATH statement.
    The other suggestion to use a hash is really good and I will look at that because, if nothing else, it saves typing!
    Thanks again.

    Stevee