for forcearray what i do is choose elements which i know can be either
repeating, and turn it on for those elements only.  it turns out to be
fairly easy to program at that point.  my coworker had to play around with
keyattr to get things right too.

i love XML::Simple for its simplicity, but the order thing has been kind of
a problem for me too.  is it possible that the hash implementation could be
changed by XML::Simple so that it always maintains order?  this may be a
ridiculous notion, i haven't explored perl in this way before.

-a

> -----Original Message-----
> From: Grant McLean [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 07, 2001 7:53 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Cc: 'Morbus Iff'
> Subject: RE: XML::Simple and Attribute/Non-Attribute Output...
> 
> 
> Hi
> 
> If you set the 'forcearray' option to true when you call XMLin()
> then XMLout() will be able to remember which values were 
> attributes and which were nested elements.  However the order
> of the elements will be lost due to things being stored in a
> hashref.  Of course with everything in an array, you'll need to
> say:
> 
>   $opml->{head}->[0]->{title}->[0];
> 
> instead of:
> 
>   $opml->{head}->{title};
> 
> XMLout() also has a 'noattr' option if you always want to use
> nested elements rather than attributes but in your case you need
> both.
> 
> If the element order is critical to your application, XML::Simple
> is not likely to prove suitable.
> 
> You might want to take a look at XML::XPath.
> 
> Regards
> Grant
> 
> =====================================================================
> Grant McLean       | email: [EMAIL PROTECTED] | Lvl 6, BP House
> The Web Limited    | WWW:   www.web.co.nz    | 20 Customhouse Quay
> Internet Solutions | Tel:   +64 4 495 8250   | Box 1195, Wellington
> Awesome service    | Fax:   +64 4 495 8259   | New Zealand
> 
> 
> 
> > -----Original Message-----
> > From: Morbus Iff [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, February 01, 2001 12:38 PM
> > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> > Subject: XML::Simple and Attribute/Non-Attribute Output...
> > 
> > 
> > I'm hoping to use XML::Simple to read in and out OPML 
> > formatted documents.
> > Very roughly, they look like:
> > 
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <opml version="1.0">
> >     <head>
> >             <title>mySubscriptions</title>
> >             <dateCreated>Fri, 05 Jan 2001 02:22:28 GMT</dateCreated>
> >             <dateModified>Mon, 29 Jan 2001 17:29:01 
> > GMT</dateModified>
> >             <ownerName>Morbus Iff</ownerName>
> >             <ownerEmail>[EMAIL PROTECTED]</ownerEmail>
> >             <expansionState></expansionState>
> >             <vertScrollState>1</vertScrollState>
> >             <windowTop>294</windowTop>
> >             <windowLeft>319</windowLeft>
> >             <windowBottom>494</windowBottom>
> >             <windowRight>704</windowRight>
> >     </head>
> >     <body>
> >             <outline text="freshmeat.net" description="the
> > one-stop-shop for all your Linux software needs"
> > htmlUrl="http://freshmeat.net" language="unknown" 
> > title="freshmeat.net"
> > type="rss" version="RSS" 
> > xmlUrl="http://freshmeat.net/backend/fm.rdf"/>
> >     </body>
> > </opml>
> > 
> > Sucking this document in through XML::Simple using the 
> > defaults is fine.
> > Throwing it out correctly creates the outline attributes in a random
> > order... But, it also attributes all of the entities in <head> like:
> > 
> >   <head vertScrollState="1" title="mySubscriptions" windowLeft="319"
> > ownerEmail="[EMAIL PROTECTED]" windowRight="704" 
> > dateCreated="Fri, 05 Jan
> > 2001 02:22:28 GMT" windowTop="294" ownerName="Morbus Iff"
> > windowBottom="494" dateModified="Mon, 29 Jan 2001 17:29:01 GMT">
> >     <expansionState></expansionState>
> >   </head>
> > 
> > Is it possible for me to output the OPML the right way using some of
> > XML::Simple's magic config options? I've been messing with 
> > keyattr, and
> > similar, but haven't had any luck.
> > 
> > Likewise, if anyone know of an OPML read/writer in Perl, I'd 
> > be obliged for
> > knowledge.
> > 
> > -- 
> > Morbus Iff
> >                  We have QuadrapalegicMorbus - able to lay 
> > still on tall
> >    o-/----'   servers for days at a time, slower than 
> > Christopher Reeve at
> >                 a full roll, smells stronger than 128 
> > poobits. Defender
> >                      of Bedsores, Boredom and Bedpans of Shat...
> >                    Devil Shat: <http://www.disobey.com/devilshat/>
> > 
> > -02--- <\/> ---- <http://www.disobey.com/> --- Bad Ascii, 
> > Short Notice ----
> > 
> > _______________________________________________
> > Perl-XML mailing list
> > [EMAIL PROTECTED]
> > http://listserv.ActiveState.com/mailman/listinfo/perl-xml
> > 
> _______________________________________________
> Perl-XML mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-xml
> 

Reply via email to