in reply to Perl Script to populate Dropdown box from XML Attributes

As of 2016, Perl is still not widely supported by browsers as a client-side scripting language. I fear you are going to have to rethink your approach here. Either use Perl on the server side before sending the document to the browser or else consider some other language to do it on the client side.

  • Comment on Re: Perl Script to populate Dropdown box from XML Attributes

Replies are listed 'Best First'.
Re^2: Perl Script to populate Dropdown box from XML Attributes
by vikrammohan (Initiate) on Nov 22, 2016 at 23:44 UTC

    Client-side server has Active perl installed in it, so we don't have any problem running Perl Script on the browser. So can you help me achieve this with Perl Script? Thanks!

      my $xp = XML::XPath->new(filename => 'State.xml');

      I doubt that the file State.xml is available on the client, where the code runs.

      Or even if that file is on the client, you will need to specify the full path to it, and even then I doubt that the Internet Explorer scripting sandbox will easily allow access to the file.

        The file State.xml is present in the same folder as the HTML. I did change the path as below:

        my $xp = XML::XPATH->new(filename => 'D://New folder//State.xml');

        But it did not work. Can you help to do it?

      Client-side Server
      … sounds like an Oxymoron to me (except if you're using Terminal Servers or some such). Perhaps you should elaborate on your setup.

      PerlScript documentation says it's an optional component, so, even if ActivePerl is installed, PerlScript might not. That documentation page also contains an example "Client-side PerlScript". Does that work?

        Its not a terminal server. But it has Perl Script on it. "perl -v" on cmd brings up this:

        This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail)

        Copyright 1987-2001, Larry Wall

        Binary build 631 provided by ActiveState Tool Corp. http://www.ActiveState.com Built 17:16:22 Jan 2 2002

        Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.

        Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If you have access to the Internet, point your browser at http://www.perl.com/, the Perl Home Page.

        I have gone through the Client-side PerlScript example:

        <html> <head> <title>PerlScript Hello World!</title> </head> <body bgcolor="#ffffff"> <h2>PerlScript Hello world!</h2> <script language="PerlScript"> $window->document->write('Hello world!'); </script> </body> </html>

        This works with the below meta tag in the <head> section

        <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=8" /> <title>PerlScript Hello World!</title> </head> <body bgcolor="#ffffff"> <h2>PerlScript Hello world!</h2> <script language="PerlScript"> $window->document->write('Hello world!'); </script> </body> </html>

        The above code works fine but I am asked not to use meta tag work around. And even after using meta tag, my original code is not working.

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>demo of dropdown list using xml element data in PerlScript</ti +tle> </head> <body> <SELECT id="STATE" style="WIDTH: 100px; "> <option value="" selected></option> <SCRIPT language="PerlScript"> use strict; use warnings; use feature 'say'; use XML::XPath; my $xp = XML::XPath->new(filename => 'State.xml'); my $querysshh = '/States/State'; $nodeset = $xp->find($querysshh); foreach $mynode ($nodeset->get_nodelist) { my $statenames = $myNode->getAttribute('Name'); print $statenames; $window->document->write("<option value='".$staten +ames."'>".$statenames."</option>"); } </SCRIPT> </SELECT> </body> </html>

        We use IE9 & IE11. So used the below code in the <script> tag

        HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState\PerlScript\1.0 REG_DWORD: EnabledZones = 0x0010 (default)

        Still it did not work. Can you help me to understand the problem with my code better and how to make it work? Thanks!