basicdez has asked for the wisdom of the Perl Monks concerning the following question:
As near as I can tell I could do the following in Perl to create this tree...<?xml version = "1.0"?> <Application> <Customer> <Name> "Fred Flintsone" </Name> <Address> "111 Rock River Lane" </Address> </Customer> <Customer> <Name> "Barney Rubble" </Name> <Address> "113 Rock River Lane" </Address> </Customer> </Application>
Please tell me if there is a more efficient way of completing this task... thanks. dez L# !usr/bin/perl -w use strict; use XML::Writer; use IO; my output = new IO::File(">xxx.xml"); @Name = "Fred Flintsone", "Barney Rubble"; @Address = "111 Rock River Lane", "113 Rock River Lane"; my $writer = new XML::Writer(OUTPUT => $output,NEWLINES =>1); $writer->xmlDecl("UTF-8","1"); $writer->startTag("Application", $writer->startTag("Customer"), $writer->startTag("Name"); $writer->characters($Name[0]); $writer->endTag("Name"); $writer->startTag("Address"); $writer->characters($Address[0]); $writer->endTag("Name"); $writer->startTag("Name"); $writer->characters($Name[1]); $writer->endTag("Name"); $writer->startTag("Address"); $writer->characters($Address[1]); $writer->endTag("Address"); $writer->endTag("Customer"); $writer->endTag("Application"); $writer->end(); $output->close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with XML::Writer
by OeufMayo (Curate) on Sep 01, 2001 at 04:09 UTC | |
by basicdez (Pilgrim) on Sep 04, 2001 at 18:55 UTC | |
|
Answer: Help with XML::Writer
by mirod (Canon) on Aug 31, 2001 at 22:56 UTC |