Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: XMLout and keys/attributes

by sauoq (Abbot)
on May 09, 2012 at 15:02 UTC ( #969643=note: print w/ replies, xml ) Need Help??


in reply to XMLout and keys/attributes

Remove the ContentKey option from your call to XMLout and change where you set $XmlRef to the following:

$XmlRef->{$keyname}{'devices'}{'dev'.$cnt}{'param'} = [ {$foo => $userref->{$key}{'hash'}{$foo}} ];
Update: No, that's not right... you have two tags, so you have to push them on... Try this:
$XmlRef->{$keyname}{'devices'}{'dev'.$cnt}{'param'} = []; for my $foo(keys %{$userref->{$key}{'hash'}}) { push @{ $XmlRef->{$keyname}{'devices'}{'dev'.$cnt}{'param'} } , {id => $foo, content => $userref->{$key}{'hash'}{$foo}} ; $i+=1; }

Edit: struck out incorrect code.

-sauoq
"My two cents aren't worth a dime.";


Comment on Re: XMLout and keys/attributes
Select or Download Code
Re^2: XMLout and keys/attributes
by atreyu (Sexton) on May 09, 2012 at 15:29 UTC
    Arggg! I just looked at the original code again, and I realized I screwed up the description of the XML. here is the correct $userref example:
    $userref->{0}{'hash'}{'Name'} = 'joe'; $userref->{0}{'hash'}{'Type'} = 'user'; $userref->{0}{'hash'}{'1Param'} = 'foo';
    and here is what I need the XML to look like:
    <key0> <devices> <dev0> <param id="Name">joe</param> <param id="Type">user</param> <param id="1Param">foo</param> </dev0> </devices> </key0>
    btw, your code suggestion was very close sauoq, care to try again?!
      btw, your code suggestion was very close sauoq, care to try again?!

      I already did. See my update? ;-)

      P.S. It should work with three params as well as two, so your "arrrggg" isn't needed. :-)

      -sauoq
      "My two cents aren't worth a dime.";
        sauoq, your two cents are so money! you nailed it, thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://969643]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (16)
As of 2014-08-27 13:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (238 votes), past polls