perl script to produce xml code

Nov 14, 11:59 AM

this perl script will produce XML code. dont forget to include the CGI calls and make sure the first line points to the correct perl!

Source of this script

#!/usr/bin/perl -w
use strict;

use CGI;
use XML::Writer;

my $cgi = new CGI;

print $cgi->header(‘text/xml’);

my $doc = new XML::Writer();
$doc->xmlDecl();
 $doc->startTag(“doc”, class => “simple”);
  $doc->dataElement( title => “Simple Doc”);
   $doc->startTag( “section”);
   $doc->dataElement( title => “Introduction”, no => 1, type => “intro”);
    $doc->startTag( “para”);
     $doc->characters( “a text with”);
     $doc->dataElement( bold => “bold”);
      $doc->characters( “ words.”);
    $doc->endTag( “para”);
   $doc->endTag(‘section’); # close section
 $doc->endTag(‘doc’); # close doc
$doc->end(); # final checks

Mark Edwards

,

---

Commenting is closed for this article.

---