my $xp = XML::XPath->new(filename => $file); $plantdata->{nodeset} = $xp->find('//loop_device[@loop_number="1"]'); #### if ($devicetype eq "complex") { $seachstring = sprintf "//loop_device[@devicename=\"%s\"]/subdevice", $devicename; $subdevice = $xp->find($searchstring); } #### $subdevice = $device->find('/subdevice');