Wig, My Poor Mail client is very poor @ bottom post.... Any idea why it does not print exactly like it reads....look @ <tittle> attribute. In source file, it is almost on top, while in output it's nearly on bottom ??
Thanks Mark G ----- Original Message ----- From: Wiggins d'Anconia <[EMAIL PROTECTED]> Date: Monday, June 7, 2004 11:33 pm Subject: Re: XML::Simple > Please bottom post.... > > Mark Goland wrote: > > Wiggings, > > I should of been more clear. It does work, but does not > produce same > > output as input. My best guess, it doesn't read in all the tags > properly.> AttrIndent is just a spacing thing, if if removed still > does not work > > properly. > > > > C:\xml_parse>perl -MXML::Simple -e "print $XML::Simple::VERSION" > > 2.12 > > > > That helps. I am assuming you are talking about how it is folding > the > single tags into attributes. This seems kind of contrived but I > believe > the following produces the same structure (aka out of order but > that > isn't strict), > > #!/usr/local/bin/perl > > > use strict; > use warnings; > > > use XML::Simple; > use Data::Dumper; > > > my $ref = XMLin('./NMS.xml', > ForceArray => [ > 'itemList','menu','startPage','display','sortby','define','item','a','page' > ], > KeyAttr => [], > ) or die "$!\n"; > #print Dumper($ref); > print XMLout($ref, XMLDecl => 1, RootName => 'root', NoAttr => 1); > exit; > > The main changes are the list I had to pass to ForceArray, turning > off > the KeyAttr default list, not keeping the root element, but then > also > setting what the root element string should be, and finally > telling it > that none of the tags should be folded into attributes on output. > > I haven't come up with a good way to figure all of this out yet, > usually > I just do a lot of guess and test until it produces exactly what I > want. > Generally messing with ForceArray and KeyAttr has gotten me where > I > needed to go. You might re-examine the docs on these particular > attributes. > Helps? > > http://danconia.org > > > > ----- Original Message ----- > > From: "Wiggins d'Anconia" <[EMAIL PROTECTED]> > > To: "Mark Goland" <[EMAIL PROTECTED]> > > Cc: <[EMAIL PROTECTED]> > > Sent: Monday, June 07, 2004 10:25 PM > > Subject: Re: XML::Simple > > > > > > > >>Mark Goland wrote: > >> > >>>Hello all, > >>> I am trying to play with simple XML. I hace reated a file, and am > > > > trying to read it in using XML::Simple and write it out, but > with no luck > > :O(. Can someone point me to the correct error. > > > >>>Thanks in Advance, > >>>Mark G > >>> > >>>CODE: > >>>#!PERl -w > >>>use XML::Simple; > >>>use Data::Dumper; > >>> > >>>$ref = XMLin('.\NMS.xml', ForceArray => [ 'itemList', 'root' > > > > ,'menu' ],KeepRoot => 1,KeyAttr =>"define" ) or die "$!\n"; > > > >>>print XMLout($ref, XMLDecl => 1,AttrIndent => 1); > >>>exit; > >>> > >> > >><snip xml file> > >> > >>What version of XML::Simple are you using? My version at 2.07 > does not > >>have the 'AttrIndent' option and throws the following exception: > >> > >>"Unrecognised option: AttrIndent at ./test.pl line 13" > >> > >>Which does appear in the docs on CPAN for version 2.12. If I remove > >>that option then your program with the provided file works fine > as far > >>as I can tell, aka it runs. You didn't specifically state what > problem>>you are seeing. If this doesn't help give us the precise > meaning of what > >>isn't working, what the exact error is, etc. > >> > >>perl -MXML::Simple -e 'print $XML::Simple::VERSION' > >> > >>Should tell you your version number. > >> > >>http://danconia.org > >> > >>-- > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EMAIL PROTECTED] > >><http://learn.perl.org/> <http://learn.perl.org/first-response> > >> > >> > > > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>