in reply to Perl & Simple::XML
but if there's more than one author, XML::Simple puts in an array ref.{AuthorList => {CompleteYN=>"Y", Author => {ValidYN=>"Y", LastName=>"Dinos", ForeName=>"A E"}}}
Use the 'ForceArray' option on XMLin so that author always gets the array ref. That way your code doesn't choke on one case or the other.{AuthorList => {CompleteYN=>"Y", Author => [{ValidYN=>"Y", LastName=>"Tsirgos", ForeName=>"K T"}, {ValidYN=>"Y", LastName=>"Dinos", ForeName=>"A E"}]}}
The notes to XML::Simple say that they wish they'd made ForceArray the default. I guess there's too much established code out there to change the default now.
Read up on it. BTW, while you're there, read about KeyAttr, too. You'll want to use it.
throop
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl & Simple::XML
by Jenda (Abbot) on Oct 07, 2007 at 10:19 UTC |