joppei has asked for the wisdom of the Perl Monks concerning the following question:
So far I have this code wich I want to change to make this work. :<Invoice> <InvoiceHeader> <InvoiceType></InvoiceType> <InvoiceStatus></InvoiceStatus> <InvoiceNumber></InvoiceNumber> <InvoiceDate></InvoiceDate> <Supplier> <Name> </Name> <OrgNumber></OrgNumber> <VatId></VatId> </Supplier> </InvoiceHeader> <InvoiceDetails> <BaseItemDetails> <Description></Description> <PerQuantity></PerQuantity> <QuantityInvoiced></QuantityInvoiced> <UnitOfMeasure></UnitOfMeasure> <LineItemGrossAmount></LineItemGrossAmount> <LineItemAmount></LineItemAmount> <SuppliersProductId></SuppliersProductId> <UnitPrice></UnitPrice> <StartDate></StartDate> <EndDate></EndDate> </BaseItemDetails> <BaseItemDetails> ------------------- -------------------- ----------------- </BaseItemDetails> </InvoiceDetails> </Invoice>
How can i extract the <BaseItemDetails> for each record ? I Have no problem getting the data I need until I reach the multiple "simular" records. I can get the first "record" but clueless on how to get the next. Iv also managed to get all the <baseItemsDetails> printed out, but then i have no way of knowing wich record they belong to from the start. Wich is a big point. Whats the proper way to do this ? Do i need something different the xpath ? I`m pretty new to perl, so really any tips/advice is appriciated.foreach my $row ($xp->findnodes('Invoice')){ my $description= $row->find('InvoiceDetails/BaseItemDetails/Desc +ription')->string_value; ----------- ----------- print "$description "; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with multiple records in xml file , Xpath
by toolic (Bishop) on Mar 02, 2010 at 17:12 UTC | |
|
Re: Problems with multiple records in xml file , Xpath
by stefbv (Priest) on Mar 02, 2010 at 17:22 UTC | |
by joppei (Initiate) on Mar 02, 2010 at 19:20 UTC | |
by stefbv (Priest) on Mar 02, 2010 at 20:14 UTC | |
by Jenda (Abbot) on Mar 03, 2010 at 08:52 UTC | |
by joppei (Initiate) on Mar 05, 2010 at 13:47 UTC |