in reply to Problems with multiple records in xml file , Xpath

Here is a simple way to do it using XML::Twig:
use strict; use warnings; use XML::Twig; my $xmlStr = <<XML; <Invoice> <InvoiceHeader> <InvoiceType></InvoiceType> <InvoiceStatus></InvoiceStatus> <InvoiceNumber></InvoiceNumber> <InvoiceDate></InvoiceDate> <Supplier> <Name> </Name> <OrgNumber></OrgNumber> <VatId></VatId> </Supplier> </InvoiceHeader> <InvoiceDetails> <BaseItemDetails> <Description>desc1</Description> <PerQuantity></PerQuantity> <QuantityInvoiced></QuantityInvoiced> <UnitOfMeasure></UnitOfMeasure> <LineItemGrossAmount></LineItemGrossAmount> <LineItemAmount></LineItemAmount> <SuppliersProductId></SuppliersProductId> <UnitPrice></UnitPrice> <StartDate></StartDate> <EndDate></EndDate> </BaseItemDetails> <BaseItemDetails> <Description>desc2</Description> <PerQuantity></PerQuantity> <QuantityInvoiced></QuantityInvoiced> <UnitOfMeasure></UnitOfMeasure> <LineItemGrossAmount></LineItemGrossAmount> <LineItemAmount></LineItemAmount> <SuppliersProductId></SuppliersProductId> <UnitPrice></UnitPrice> <StartDate></StartDate> <EndDate></EndDate> </BaseItemDetails> </InvoiceDetails> </Invoice> XML my $twig= XML::Twig->new( twig_handlers => { 'BaseItemDetails/Description' => sub { print $_->text(), "\n" } } ); $twig->parse($xmlStr); __END__ desc1 desc2