Hope it's okay to write to this group regarding beginner problems with XML::Writer. 
I'm a beginner both to XML  in general, and XML::Writer in particular.

I'm trying to run this program:
============================
#! /usr/bin/perl

use XML::Writer;

my $writer = new XML::Writer(DATA_MODE => 1,
                             DATA_INDENT => 3,
                             UNSAFE =>1);

$writer->xmlDecl("ISO-8859-1");

$writer->dataElement("docnum", "PIP 189165");
$writer->startTag("greeting",
                  "class" => "simple");
$writer->characters("Hello, world!");
$writer->endTag("greeting");

$writer->end();
============================
When I do, I get the output I think I want:
[EMAIL PROTECTED]:~/POPLINE_XML$ ./test.pl                                             
                                  
<?xml version="1.0" encoding="ISO-8859-1"?>

<docnum>PIP 189165</docnum>
<greeting class="simple">Hello, world!</greeting>
[EMAIL PROTECTED]:~/POPLINE_XML$ 

This output looks like valid XML to me. I don't see any problems with it.

However, when I remove the UNSAFE and change the third line to:
my $writer = new XML::Writer(DATA_MODE => 1,
                             DATA_INDENT => 3);

I get this output:
[EMAIL PROTECTED]:~/POPLINE_XML$ ./test.pl      
<?xml version="1.0" encoding="ISO-8859-1"?>

Attempt to insert start tag after close of document element at ./test.pl line 11
<docnum>PIP 189165</docnum>[EMAIL PROTECTED]:~/POPLINE_XML$ 

I don't understand what I'm doing wrong to cause XML::Writer to complain. Do I not 
understand XML correctly?

Thanks for your thoughts and suggestions.

-Kevin Zembower

-----
E. Kevin Zembower
Unix Administrator
Johns Hopkins University/Center for Communications Programs
111 Market Place, Suite 310
Baltimore, MD  21202
410-659-6139


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to