Solved

creating xml output with perl

Posted on 2008-10-17
3
518 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

808 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