Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] XML::Simple ForceArray problem

Expand Messages
  • Bill Walton
    Oops ;-( The structure of the file is actually: IDNum Sponsor A
    Message 1 of 1 , Dec 27, 2005
    View Source
    • 0 Attachment
      Oops ;-(

      The structure of the file is actually:

      <study>
      <study_id>IDNum</study_id>
      <sponsors>
      <lead_sponsor>
      <agency>Sponsor A</agency>
      </lead_sponsor>
      <collaborator>
      <agency>Sponsor B</agency>
      </collaborator>
      <collaborator>
      <agency>Sponsor C</agency>
      </collaborator>
      </sponsors>
      </study>

      ----- Original Message -----
      From: Bill Walton
      To: perl-beginner@yahoogroups.com
      Sent: Tuesday, December 27, 2005 3:53 PM
      Subject: [PBML] XML::Simple ForceArray problem


      Greetings!

      I'm processing XML files and am having trouble accessing some of the data.

      The (simplified) file structure of the situation I'm having trouble with is:

      <study>
      <study_id>IDNum</study_id>
      <sponsors>
      <lead_sponsor>Sponsor A</lead_sponsor>
      <collaborator>Sponsor B</collaborator>
      <collaborator>Sponsor C</collaborator>
      </sponsors>
      </study>

      There is one occurrance of <lead_sponsor> in each file. There are zero or more occurrances of <collaborator>.

      I've tried using forcearray => ['sponsors'] in the XMLin statement, but when I try to get the number of items under <sponsors> using
      $ArraySize = @{$Study->{sponsors}};
      I always get '1' for $ArraySize.

      Additionally, while I don't get an error executing
      $TrialSponsor = $Study->{sponsors}[$i]->{agency};
      I get a "Use of unitialized value..." warning when I try to print $TrialSponsor.

      How can I access the second (third, fourth, etc.) occurrance of <collaborator>?

      Thanks in advance for your assistance.

      Best regards,
      Bill

      [Non-text portions of this message have been removed]



      Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html



      ------------------------------------------------------------------------------
      YAHOO! GROUPS LINKS

      a.. Visit your group "perl-beginner" on the web.

      b.. To unsubscribe from this group, send an email to:
      perl-beginner-unsubscribe@yahoogroups.com

      c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


      ------------------------------------------------------------------------------



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.