RE: :Writer beginner problems
From: Rob Hanson (rhanson_at_aptegrity.com)
Date: 02/03/04
- Next message: Sam Masiello: "RE: Timing out without alarm function"
- Previous message: Daniel Staal: "Re: Timing out without alarm function"
- Maybe in reply to: Kevin Zembower: "RE: :Writer beginner problems"
- Next in thread: Michael C. Davis: "what is a pseudohash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: 'KEVIN ZEMBOWER' <KZEMBOWE@jhuccp.org>, beginners@perl.org Date: Tue, 3 Feb 2004 12:46:26 -0500
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <docnum>PIP 189165</docnum>
> <greeting class="simple">Hello, world!</greeting>
> ...
> Attempt to insert start tag after close of document
> element at ./test.pl line 11
A rule of XML is that there MAY ONLY BE ONE ROOT ELEMENT. You have two.
You need to put <docnum> and <greeting> inside a single element. The
following would be well-formed XML.
<?xml version="1.0" encoding="ISO-8859-1"?>
<rootTag>
<docnum>PIP 189165</docnum>
<greeting class="simple">Hello, world!</greeting>
</rootTag>
Rob
-----Original Message-----
From: KEVIN ZEMBOWER [mailto:KZEMBOWE@jhuccp.org]
Sent: Tuesday, February 03, 2004 12:41 PM
To: beginners@perl.org
Subject: XML::Writer beginner problems
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:
kevinz@www:~/POPLINE_XML$ ./test.pl
<?xml version="1.0" encoding="ISO-8859-1"?>
<docnum>PIP 189165</docnum>
<greeting class="simple">Hello, world!</greeting>
kevinz@www:~/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:
kevinz@www:~/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>kevinz@www:~/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: beginners-unsubscribe@perl.org For additional commands, e-mail: beginners-help@perl.org <http://learn.perl.org/> <http://learn.perl.org/first-response>
- Next message: Sam Masiello: "RE: Timing out without alarm function"
- Previous message: Daniel Staal: "Re: Timing out without alarm function"
- Maybe in reply to: Kevin Zembower: "RE: :Writer beginner problems"
- Next in thread: Michael C. Davis: "what is a pseudohash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|