Hello: I am currently designing a data object builder for that extrapolates clinical data from an XML export and imports into a ASCII format. (Oh the joys of a clinical systems analyst.) Anyway, my issue is that my initial procedural format for my code works. I can read the file name, parse it using XML::DOM and spit out something resembling the ASCII format I need. however, whenever I use my new HemoCode:
package CathRecord; require XML::DOM; use strict; use Class::Struct; struct CathRecord => { PatDemo => '@', CathEvents => '%', Procedures => '%', CathStaff => '%', CathBlood => '%', CathEvent => '%', CathSat => '%', CathAldrete => '%', }; 1; sub CamPatDemo { my $file = $_[0]; my $obj = CathRecord->new(); my $parser = XML::DOM::Parser->new(); my $doc = $parser->parsefile($file); my @patdemo; my ($ln, $fn, $sex, $dob, $htu, $htn, $wtu, $wtn, $patnum, $patien +t); #Get Patient Data foreach $patient($doc->getElementsByTagName('SA_PATIENT')) { $ln = $patient->getElementsByTagName('MY_LAST_NAME')->item(0)- +>getFirstChild->getNodeValue; $fn = $patient->getElementsByTagName('MY_FIRST_NAME')->item(0) +->getFirstChild->getNodeValue; $dob = $patient->getElementsByTagName('MY_BIRTH_DATE')->item(0 +)->getFirstChild->getNodeValue; $sex = $patient->getElementsByTagName('MY_GENDER')->item(0)->g +etFirstChild->getNodeValue; $dob = $patient->getElementsByTagName('MY_BIRTH_DATE')->item(0 +)->getFirstChild->getNodeValue; } foreach $patient($doc->getElementsByTagName('CathStudy')) { $htn = $patient->getElementsByTagName('PatHeight')->item(0)->g +etFirstChild->getNodeValue; $wtn = $patient->getElementsByTagName('PatWeight')->item(0)->g +etFirstChild->getNodeValue; $htu = $patient->getElementsByTagName('PatHeight')->item(0)->g +etAttribute('Units'); $wtu = $patient->getElementsByTagName('PatWeight')->item(0)->g +etAttribute('Units'); $patnum = $patient->getElementsByTagName('StudyID')->item(0)-> +getFirstChild->getNodeValue; } @patdemo = [$ln, $fn, $dob, $sex, $dob, $htn, $htn, $wtu, $wtn, $p +atnum]; $obj->{'PatDemo'} = @patdemo; return $obj-{'PatDemo'}; }
I get the following error:
H:\My Documents\HemoKit>perl m6.pl Couldn't open CathRecord=HASH(0x234ee0): No such file or directory at CathRecord.pm line 25
For some reason, my module is unable to accept a string. It keeps referring to my entry as a hash. Here is my input code:
#!/usr/bin/perl -w use XML::DOM; use CathRecord; ### Create New Object my $file = "H:/My Documents/files/mfrTESTa.XML"; my $obj = CathRecord->new(); my @sa = $obj->CamPatDemo($file);
Is it the module or the way I am accessing its attributes. Regards - Cappadonna

In reply to Attempting to read file name into my XML Parsing Object by Cappadonna3030

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.