"Derek Wueppelmann" <[EMAIL PROTECTED]> writes:

> On Tue, 27 Nov 2001, Igor Vrdoljak wrote:
> 
> > sub PrintSTOUT  {
> >     my ($doc) = @_;
> >     XML::Xerces::DOMParse::unformat ($doc);
> >     XML::Xerces::DOMParse::format ($doc);
> >     XML::Xerces::DOMParse::print (\*STDOUT, $doc);
> > }
> > 
> > sub PrintFile   {
> >     my ($doc) = @_;
> >     my $string = $doc->serialize();
> >     open FP, $XML_TEST_FILE;
> >     print FP $string;
> > 
> > }
> > 
> > Now, PrintSTOUT works, but PrintFile does not.
> > I would be grateful if you helped...
> 
> Why don't you do someting like this inside of PrintFile instead...
> 
> sub PrintFile {
>    my ($doc) = @_;
>    my (*FP);
> 
>    open FP, $XML_TEST_FILE;
>    XML::Xerces::DOMParse::print(\*FP, $doc);
> }

Yes, that should work. 

Also you are not checking the return value of open(), this is a
Very-Bad-Idea (TM). You might be getting an error and just tossing it
off trying to use a non-existing file handle.

And it just so happens that you are opening the filehandle READONLY
which means that print isn't likely to do very much. Try:

   open(FP, ">$XML_TEST_FILE")
        or die "Couldn't open $XML_TEST_FILE for writing";

jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to