Sponsored Content
Full Discussion: XML::Simple Help!
Top Forums Shell Programming and Scripting XML::Simple Help! Post 302483678 by novera on Tuesday 28th of December 2010 04:58:10 AM
Old 12-28-2010
XML::Simple Help!

I can loop through each roomtype but if a roomtype has more that one mealtype I get this error:
Not a HASH reference

The ForceArray option is enabled. Please Help!


This is the dump from the XML that is begin returned to me:
---------------------------------------------------------------

Code:
$VAR1 = {
          'success' => 'true',
          'data' => {
                    'bb' => {
                            'roomtypes' => {
                                           'roomtype' => [
                                                         {
                                                           'rtimage' => '10002-2.jpg',
                                                           'ratescheme' => '1',
                                                           'rtid' => '2',
                                                           'roomsfree' => '2',
                                                           'childpolicy' => {
                                                                            'general' => '2 - 12 years stay',
                                                                            'allowchild2' => 'Y',
                                                                            'allowchild1' => 'Y'
                                                                          },
                                                           'mealtypes' => {
                                                                          'mealtype' => [
                                                                                        {
                                                                                          'defaultmealtype' => 'true',
                                                                                          'rates' => {
                                                                                                     'pax3' => '1180.00',
                                                                                                     'pax2' => '930.00',
                                                                                                     'pax4' => '1405.00',
                                                                                                     'pax1' => '550.00'
                                                                                                   },
                                                                                          'mealtypedesc' => 'Bed & Breakfast',
                                                                                          'rateid' => '6'
                                                                                        },
                                                                                        {
                                                                                          'rates' => {
                                                                                                     'pax3' => '850.00',
                                                                                                     'pax2' => '700.00',
                                                                                                     'pax4' => '975.00',
                                                                                                     'pax1' => '450.00'
                                                                                                   },
                                                                                          'mealtypedesc' => 'Self-catering',
                                                                                          'rateid' => '7'
                                                                                        }
                                                                                      ]
                                                                        },
                                                           'maxoccupancy' => '6',
                                                           'minlos' => '0',

                                                         },
                                                         {
                                                           'ratescheme' => '1',
                                                           'rtid' => '1',
                                                           'roomsfree' => '5',
                                                           'description' => 'Double bed',
                                                           'childpolicy' => {
                                                                            'general' => '2 - 12 years stay',
                                                                            'allowchild2' => 'Y',
                                                                            'allowchild1' => 'Y'
                                                                          },
                                                           'mealtypes' => {
                                                                          'mealtype' => {
                                                                                        'defaultmealtype' => 'true',
                                                                                        'rates' => {
                                                                                                   'pax2' => '800.00',
                                                                                                   'pax1' => '500.00'
                                                                                                 },
                                                                                        'mealtypedesc' => 'B&B',
                                                                                        'rateid' => '5'
                                                                                      }
                                                                        },
                                                           'maxoccupancy' => '2',
                                                           'minlos' => '0',
                                                         }
                                                       ]
                                         },
                          },
                    'nights' => '1',
                    'enddate' => '2011-01-24',
                    'startdate' => '2011-01-23'
                  }
        };


Last edited by pludi; 12-28-2010 at 06:10 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove xml namespace from xml file using shell script?

I have an xml file: <AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Table1> <Data1 10 </Data1> <Data2 20 </Data2> <Data3 40 </Data3> <Table1> </AutoData> and I have to remove the portion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" only. I tried using sed... (10 Replies)
Discussion started by: Gary1978
10 Replies

2. Shell Programming and Scripting

Perl - problem with CPAN module XML::Simple

Hi All, I am trying to run the following program #!/usr/bin/perl # use module use XML::Simple; use Data::Dumper; # create object $xml = new XML::Simple; # read XML file $data = $xml->XMLin("dump.xml"); # print output print Dumper($dump); At first i had the error mesage saying... (5 Replies)
Discussion started by: userscript
5 Replies

3. Shell Programming and Scripting

using XML::simple in shell scripting

CPAN provide xml::simple module which can be used to generate XML files. can i use this module in shell scripting? how? plzz give me an example to generate xml file using this module . you can also use some other module.. BUT SHELL SCRIPTING SHOULD ONLY BE USED (4 Replies)
Discussion started by: cynosure2009
4 Replies

4. Shell Programming and Scripting

Simple XML file comparison and merging

Okay, first of all, thanks to everyone who's helped me out before... I appreciate the opportunity to learn. I have two iTunes XML files, and I simply want to compare the contents, then merge. Theoretically, this will allow me to merge two libraries, keeping playlists intact (depending on iTunes'... (4 Replies)
Discussion started by: karlp
4 Replies

5. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

6. Shell Programming and Scripting

How to add the multiple lines of xml tags before a particular xml tag in a file

Hi All, I'm stuck with adding multiple lines(irrespective of line number) to a file before a particular xml tag. Please help me. <A>testing_Location</A> <value>LA</value> <zone>US</zone> <B>Region</B> <value>Russia</value> <zone>Washington</zone> <C>Country</C>... (0 Replies)
Discussion started by: mjavalkar
0 Replies

7. Shell Programming and Scripting

Shell Command to compare two xml lines while ignoring xml tags

I've got two different files and want to compare them. File 1 : HTML Code: <response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record... (1 Reply)
Discussion started by: Shaishav Shah
1 Replies

8. Shell Programming and Scripting

Split xml file into multiple xml based on letterID

Hi All, We need to split a large xml into multiple valid xml with same header(2lines) and footer(last line) for N number of letterId. In the example below we have first 2 lines as header and last line as footer.(They need to be in each split xml file) Header: <?xml version="1.0"... (5 Replies)
Discussion started by: vx04
5 Replies

9. UNIX for Beginners Questions & Answers

How to pull multiple XML tags from the same XML file in Shell.?

I'm searching for the names of a TV show in the XML file I've attached at the end of this post. What I'm trying to do now is pull out/list the data from each of the <SeriesName> tags throughout the document. Currently, I'm only able to get data the first instance of that XML field using the... (9 Replies)
Discussion started by: hungryd
9 Replies
All times are GMT -4. The time now is 07:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy