Jump to content


This topic is now archived and is closed to further replies.


PERL: XML output to HTML table

Recommended Posts

I want my PErl to output the content of XML to HTML table like this:

<table border="1">

<td><a href="../search.asp?ID=123456">John Doe</a></td>

<td><a href="../search.asp?ID=05789">Jack Doe</a></td>

<td><a href="../search.asp?ID=654321">Jane Doe</a></td>


<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Comment -->

      <name>John Doe</name>
      <name>Jack Doe</name>
      <name>Jane Doe</name>


print "Content-Type: text/html\n\n";
use XML::Simple;
use Data::Dumper;

my $ref = XMLin('address.xml');

print('<table border="1">\n

foreach my $type (qw(Work Relative)) {
   foreach my $person (keys %{$ref->{$type}}) {
       my $id=$ref->{$type}->{$person}->{id};
       my $name=$ref->{$type}->{$person}->{name};
      print("<a href='../search.asp?ID=$id'>$name</a>");

I just need how to fix my foreach loop. Any help?

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.