Home > Archive > PERL Beginners > July 2006 > Re: XML: :Simple -- still can't print: Dumper OK
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: XML: :Simple -- still can't print: Dumper OK
|
|
|
| > Did you enable ForceArray?
>
> Did you use Data::Dumper to look at the structure of
what XML::Simple returned?
Yes to both. I've attached the Dumper output.
(outp.txt). Given the attached xml file, and your
first snippet/example, I tried to do something very
simple: print out my dataschema name:
foreach $d (@{$data->{dataschemas}}) {
print "Dataschema: $d->{name}\n";
}
It won't print. I won't include all the variants on
the $d->{name} line I've tried, but all the results
are the same: nothing outputs.
BW
________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
| |
| Mumia W. 2006-07-25, 6:57 pm |
| On 07/25/2006 03:36 PM, BW wrote:
> Mumia W. wrote:
>
> Yes to both. I've attached the Dumper output.
> (outp.txt). Given the attached xml file, and your
> first snippet/example, I tried to do something very
> simple: print out my dataschema name:
>
> foreach $d (@{$data->{dataschemas}}) {
Why {dataschemas} when the data is in {dataschema} (no "s")?
> print "Dataschema: $d->{name}\n";
> }
>
> It won't print. I won't include all the variants on
> the $d->{name} line I've tried, but all the results
> are the same: nothing outputs.
>
> [...]
> $VAR1 = {
> 'dataschema' => {
> [...]
This was the purpose of using Data::Dumper--to show that all
of the data is under {dataschema}. People use Data::Dumper to
find out what the structure of their data is, and then write a
program to deal with that structure.
Also, please enable strictures and warnings for your program
by placing these lines at the top:
use strict;
use warnings;
Then modify your program to run under these conditions (a lot
of work, but it pays off in bug prevention.)
From the XML::Simple doc, did you read this?
> · check out "ForceArray" because you'll almost certainly want to turn
> it on
XML::Simple does some pretty weird stuff unless you use
ForceArray, so always use ForceArray; ForceArray is what makes
XML::Simple simple.
And please don't snip attributions.
| |
|
| > And please don't snip attributions.
Firstly, to make sure I'm exercising proper etiquette
here, could you please explain what I snipped so that
I don't do that in the future?
I finally got this working. I'd been leaving out one
of the items in my hash dereference string. Once I
put that item in place, I started seeing output.
Thanks for all your assistance.
--- "Mumia W." <mumia.w.18.spam+nospam@earthlink.net>
wrote:
> On 07/25/2006 03:36 PM, BW wrote:
> of
> very
>
> Why {dataschemas} when the data is in {dataschema}
> (no "s")?
>
> on
> results
>
> This was the purpose of using Data::Dumper--to show
> that all
> of the data is under {dataschema}. People use
> Data::Dumper to
> find out what the structure of their data is, and
> then write a
> program to deal with that structure.
>
> Also, please enable strictures and warnings for your
> program
> by placing these lines at the top:
>
> use strict;
> use warnings;
>
> Then modify your program to run under these
> conditions (a lot
> of work, but it pays off in bug prevention.)
>
> From the XML::Simple doc, did you read this?
almost[color=darkred]
> certainly want to turn
>
> XML::Simple does some pretty weird stuff unless you
> use
> ForceArray, so always use ForceArray; ForceArray is
> what makes
> XML::Simple simple.
>
> And please don't snip attributions.
>
>
>
> --
> To unsubscribe, e-mail:
> beginners-unsubscribe@perl.org
> For additional commands, e-mail:
> beginners-help@perl.org
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
>
>
>
________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
| |
| Mumia W. 2006-07-26, 6:57 pm |
| On 07/26/2006 11:08 AM, BW wrote:
> Firstly, to make sure I'm exercising proper etiquette
> here, could you please explain what I snipped so that
> I don't do that in the future?
>
> I finally got this working. I'd been leaving out one
> of the items in my hash dereference string. Once I
> put that item in place, I started seeing output.
>
> Thanks for all your assistance.
>
You're welcome.
> --- "Mumia W." <mumia.w.18.spam+nospam@earthlink.net>
> wrote:
>
That's an attribution.
|
|
|
|
|