Solved

creating xml output with perl

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now