in reply to Newbie XML Simple reference

It sounds like your problem is due to not understanding Perl references rather than XML::Simple. This node might help you to get up to speed on both.

Replies are listed 'Best First'.
Re^2: Newbie XML Simple reference
by Sporti69 (Acolyte) on Nov 05, 2008 at 09:57 UTC
    Thanks for the link. The next hours I will look into my script again. But first I'll check out your node link.
Re^2: Newbie XML Simple reference
by Sporti69 (Acolyte) on Nov 05, 2008 at 10:44 UTC
    I checked the link(s) but now I am more worried I will not be able to make my script. Perl is, imo, quite complicated if you never saw referencing like that. How can I get a list of attributes within an element ?
    Like for this xml
    <node class="1" name="name1" type="type1" ... >
    What outputs this:
    You have 3 attributes:
    class
    name
    type
    ?
    Without using the node in code... So in a loop, and not like {node} , that is not how to program
    Keep in mind that I use the XML::Simple.
    Thanks so much for the help !!!
      Do your part, set it up.
        Sorry Guys, I am a Perl noob. My problem is that I cannot spend time studying this language. My boss wont let me
        I need an output like this:

        You have 2 tags: node and node
        In node you have attribute type and name with values k and n
        This is the output i am looking for, for this xml
        XML
        ----
        <XML> <element> <node type="k" name="n"/> <node type="i" name="q"/> </element> </XML>
        Dummy Code
        #!/usr/bin/perl -- use strict; use warnings; use XML::Simple; my $xs1 = XML::Simple->new(); my $doc = $xs1->XMLin($file, keyattr=>['????'], ForceContent=>1, Force +Array=>1); use Data::Dumper; local $Data::Dumper::Indent=1; print Dumper($doc); for my $sub ( sort keys %{ $doc->{????} } ){ for my $elem ( sort keys %{ $doc->{????}->{$sub} } ){ } }