XML::Writer beginner problems

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default 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

    Kevin Zembower Guest

  2. Similar Questions and Discussions

    1. Isn't DataGrid.Render(writer) supposed to automatically call RenderBeginTag(writer) and RenderEndTag(writer)?
      Hi, I'm trying to customize a DataGrid adding custom rows before the endTag </TABLE>, and also some html before and after the control itself. So...
    2. PDF Writer
      Hi, I have had to reinstall my Acrobat Version 5. Previously when I clicked on print I would be offered a choice of using PDF writer or distiller....
    3. :Writer beginner problems
      > <?xml version="1.0" encoding="ISO-8859-1"?> A rule of XML is that there MAY ONLY BE ONE ROOT ELEMENT. You have two. You need to put <docnum>...
    4. CD Writer
      Anyone know of any manufacturers of external CD writers for a Blade2000 running Solaris8 thanks
    5. CD Writer problems Plextor24/10/40A on a SUN ultra 10
      Hi, Was wondering if anyone hade come across the following problem & how they resolved it. I've been given a Plextor 24/10/40A and I've...
  3. #2

    Default Re: XML::Writer beginner problems

    KEVIN ZEMBOWER wrote:
    > 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.
    Well, you are working with a Perl interface, so it's not really too off-topic. On the other hand, the content of your error messages points strongly to anXML
    error as the root problem. Your best range of help would probably come from an XML group. When you post to them, though, focus on the content of the XML
    being parsed, rather than the Perl code used to generate it.

    Joseph

    R. Joseph Newton Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139