My perl program is as follows:<Project> <Contacts> <Contact type="Application"> <Name>Shawn Penn</Name> <WorkPhone>111-111-1111</WorkPhone> <Pager>999-999-9999</Pager> <Scope>Manager</Scope> </Contact> <Contact type="Application"> <Name>George Lucos</Name> <WorkPhone>111-111-1111</WorkPhone> <Pager>999-999-9999</Pager> <Scope>Manager</Scope> </Contact> </Contacts> </Project>
The perl script runs but it does not pull in any data with the getElementsByTagName() call. It Doesn't even run the for loop. Any ideas?#!/usr/bin/perl -w use CGI qw(:standard :html :forms); use strict; use XML::XPath; use XML::XPath::XMLParser; use XML::DOM; #------------------------------- # Declare variables my $WebPage = CGI::new(); ### Create web page output des +tination ### Pull in application name of file to read from my $SourceXMLDir = "/doc/staging/ProjectInfo/" . $WebPage->param(App) +. ".xml"; ### Open XML file my $XMLFile = XML::XPath->new( filename => $SourceXMLDir ); my $ParseFile = new XML::DOM::Parser; my $XMLDOMFile = $ParseFile->parsefile ($SourceXMLDir ); #---------------END File Declaration----- ### header print $WebPage->header, $WebPage->start_html("Project Information for $ProjectName"); print "\n"; print $WebPage->h1("Contact Information for $ProjectName"), $WebPage->hr, "<table BORDER COLS=2 WIDTH=100% NOSAVE>\n", "<tr><th>Primary</th><th>Secondary</th></tr>\n", "<tr><td>", $XMLFile->find( "/Project/Contacts/Contact[\@type='Primary']/N +ame/text()" ), "</td><td>", $XMLFile->find( "/Project/Contacts/Contact[\@type='Secondary'] +/Name/text()" ), " </td></tr>\n", "</table>\n"; my $AppNode = $XMLDOMFile->getElementsByTagName ("Contact"); my $numberNodes = $AppNode->getLength; print "<table BORDER COLS=4 WIDTH=100% >\n", "<tr><th>Scope</th><th>Name</th><th>Work Phone</th><th>Pager</ +th></tr>\n", "<tr>\n"; for (my $loopIndex = 0; $loopIndex < $numberNodes; $loopIndex++) { "<td>", my $ScopeText = $AppNode->item($loopIndex)->getFirstChild()->g +etNodeValue(); } "</td>\n</tr>", "</table>\n"; print "\n"; print $WebPage->end_html; print "\n";
In reply to XML::DOM::Parser not getting data by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |