Solved

creating xml output with perl

Posted on 2008-10-17
3
521 Views
Last Modified: 2013-12-25
THIS IS THE XML STRUCTURE I NEED ( for  use with  ADOBE SPRY Framework)

<photos id = "images">
<photo
path = "travel_01.jpg"
width = "263"
height = "350"
thumbpath = "travel_01.jpg"
thumbwidth = "56"
thumbheight = "75">
</photo>
</photos>

I CAN MAKE XML FOR SINGLE  PHOTO NAMES:
print header(-type=>'text/xml',-expires=>'+3d'),
 start_html('XML test'),
    '<image>',
  (map$q->p("<imagename> $_</imagename>"), @image_list),
   '</image>',
  $q->end_html;
 

WHAT I NEED TO KNOW:
How to create the structure used by the SPRY framework using CGI.pm.

Thank you






<photos id = "images">

<photo
path = "travel_01.jpg"
width = "263"
height = "350"
thumbpath = "travel_01.jpg"
thumbwidth = "56"
thumbheight = "75">
</photo>
</photos>
0
Comment
Question by:darmcqueen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 22749579
CGI.pm is for HTML not XML
you probably start with using XML::Simple
0
 

Accepted Solution

by:
darmcqueen earned 0 total points
ID: 22750617
THIS IS THE SOLUTION THAT I WORKED OUT:

use strict;
use XML::Writer;
use CGI qw/:standard/;

print(header(-type  => 'application/xml'));
 
my $writer = new XML::Writer();

$writer ->startTag ("photos");

foreach my $image(@image_list){

$writer ->startTag ("photo",
                   
path => "$image",
width => "263",
height => "350",
thumbpath => "$image",
thumbwidth => "56",
thumbheight => "75",                  
     );

$writer->endTag("photo");

} # end images

$writer->endTag("photos");
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question