|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
XML::Simple Data::Dumper w Perl
Here is the code that reads in the XML file, parses it using XML::Simple and dumps the contents to screen:
use XML::Simple; use Data: umper;my $xml = ""; open(FILE, "sampleOrder.xml") || die "Cannot open data file"; while (<FILE>) { $xml .= $_; } close FILE; my $hashref = XMLin($xml); print Dumper($hashref); What I see is a bunch of embedded hashes similar to this: $VAR1 = { 'Message' => [ { 'TestOrderRequest' => { 'FulfillmentData' => { 'FulfillmentServiceLevel' => 'Standard', 'PostalCode' => '98004', 'FulfillmentMethod' => 'Ship', 'FulfillmentCenterID' => '0' }, 'Item' => { 'SKU' => '1234', 'Quantity' => '2' }, 'BillingData' => { 'CreditCard' => { 'Issuer' => 'Visa' }, 'BuyerEmailAddress' => 'joesmith@hotmail.com' } }, 'MessageID' => '1' }, What I would like is a simple way to extract into variables that contain values, eg. $firstName = $myValues{'firstName'} Does anyone know how this can be done without having to know the tree structure of the hashes? Please forgive the newbieness... Last edited by bwebb@SCGI : July 26th, 2002 at 01:08 PM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XML::Simple Data::Dumper w Perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|