?
Solved

creating xml output with perl

Posted on 2008-10-17
3
Medium Priority
?
530 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
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…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

762 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