Re: Not an ARRAY reference
jtbutler...@xxxxxxxxxxx wrote:
> I am reading an XML file in perl and looping through the items and
> manipulating data. If I have 2 or more 'menuitems' in my xml file it
> works ok. if i only have one like the code below I get "Not an ARRAY
> reference" at the foreach line - any ideas why?
>
> $create_menu = new XML::Simple (KeyAttr=>[]);
>
> $data = $create_menu->XMLin($xml_file);
>
> foreach $e (@{$data->{menuitem}}){
> .....
> }
>
see the 'ref' function.
my $type = ref( $data->{menuitem} );
print "$type\n";
my guess is, $type ne 'ARRAY'.
.
Relevant Pages
- Re: Question on arrays (newbie)
... I have figured out how to write the file with data in an array. ... Does anyone have an idea on how to create a function that will write xml file without explicit knowlege what is inside if an array? ... foreach (Disk disk in comp.disks) ... foreach ... (microsoft.public.dotnet.languages.csharp) - RE: writing to a specific point in an array file
... Hi Melanieab, ... would be in an XML file rather than a text file and trying to manipulate ... basically writing an empty string over the current row. ... > array file, but I wasn't sure how to replace just one item. ... (microsoft.public.dotnet.languages.csharp) - Re: csproj/vbproj definition available?
... and A Project represents an MSBuild ... save to an XML file, preserving most whitespace and all XML comments." ... foreach ... foreach (BuildItemGroup itemGroup in project.ItemGroups) ... (microsoft.public.dotnet.languages.csharp) - Re: How to dynamically resize an array?
... In the previous version of the program I just gave the array a large value eg. 40 as it is unlikely any season of a TV series will have that many episodes. ... The only other way would be to read the xml file twice, firstly counting the number of episodes and then declaring the array, and then read it again and fetch in the episode data. ... XPATH is specifically designed to search for the "DOM" of the XML documentt to returns a list of elements by providing it a query statement. ... (microsoft.public.dotnet.languages.vb) - Re: ArgumentException thrown when converting a memorystream to image
... the following code will read the contents from a> file and place them into a byte array. ... >> As I read the xml file in .NET, I parse my xml, retrieve this string, and>> try to convert it into an Image object or Bitmap in the following code. ... (microsoft.public.dotnet.languages.csharp) |
|