lazix

xml_parser.pl

Nov 28th, 2020
253
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use 5.010;
  2. use strict;
  3. use warnings;
  4. use XML::LibXML;
  5. my $filename = 'info.xml';
  6. my $dom = XML::LibXML->load_xml(location => $filename);
  7. foreach my $info ($dom->findnodes('//main')) {
  8.     say 'Author: ', $info->findvalue('./author');
  9.     say 'Starting Date: ', $info->findvalue('./dateStarted');
  10.     say 'Ending Date: ', $info->findvalue('./dateEnding');
  11.     say 'Reason for the language: ', $info->findvalue('./reasonFor');
  12.     say 'Tools: ';
  13.     say 'OS: ', $info->findvalue('./os');
  14.     say 'Text Editor: ', $info->findvalue('./toolEditor');
  15.     say 'Compiler: ', $info->findvalue('./compiler');
  16.     say 'Using ', $info->findvalue('make');
  17.  
  18. }
  19.  
RAW Paste Data