Solved

creating xml output with perl

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

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.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Six Sigma Control Plans

717 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