vikrammohan has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to get the values of the dropdown box in HTML from XML tag attribute, with Perl script. This is a HTML based application, will be run on one windows server Internet explorer locally. Both the HTML and XML will be on server hard disk before running. I have problem getting the XML and also getting the XML tag attribute into the drop down box. Here is my XML file:
<States> <State Name="North" Server="Server1" Backupserver="BKserver1"></State> <State Name="South" Server="Server2" Backupserver="BKserver2"></State> <State Name="East" Server="Server3" Backupserver="BKserver3"></State> ........ </States>
Here is my HTML part:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5.0 Transitional//EN"> <html> <head><title>Get Dropdown from XML using Perlscript</title></head> <body> ......... <select id="States" name="States"> <option></option> <script language="perlscript"> use strict; use warnings; use feature 'say'; use XML::XPath; my $xp = XML::XPath->new(filename => 'State.xml'); my $queries = 'States/State'; $nodeset = $xp->find($queries); foreach $mynode ($nodeset->get_nodelist) { my $statename = $mynode->getAttribute('Name'); $window->document->write("<option value='".$statename."'>". +$statename."</option>"); } </script> </select> ..... </body> </html>
I am newbie to perl scripting and using the above Perlscrip to open the XML and populating the XML but it fails. I am not sure where it fails and how to correct it to make it work. All I want is the Dropdown box with ID "States" to have the value "North","South","East",.... while the page loads. Have crafted the above PerlScript from various other posts. These HTML and XML are in the same folder on the windows server and are opened in IE by user, while running this HTML application. Can someone help me with a solution to achieve this problem? Thank you
|
|---|