Guest User

Untitled

a guest
Sep 23rd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.90 KB | None | 0 0
  1. use XML::LibXML;
  2. use Encode;
  3. #use utf8;
  4. use File::Slurp;
  5. use   HTML::Entities;
  6. print "$ARGV[1]<<<";
  7. my $parser=XML::LibXML->new;
  8. %entity2char =
  9. ('Auml' =>                                              '196',
  10. 'Ouml'  =>                                              '214',
  11. 'Uuml'  =>                                              '220',
  12. 'szlig' =>                                              '223',
  13. 'auml'  =>                                              '228',
  14. 'ouml'  =>                                              '246',
  15. 'uuml'  =>                                              '252',
  16. 'quot'  =>                                              '34',
  17. 'amp'   =>                                              '38',
  18. 'lt'    =>                                              '60',
  19. 'gt'    =>                                              '62',
  20. 'lsqb'  =>                                              '91',
  21. 'rsqb'  =>                                              '93',
  22. 'lcub'  =>                                              '123',
  23. 'rcub'  =>                                              '125',
  24. 'nbsp'  =>                                              '160',
  25. 'iexcl' =>                                              '161',
  26. 'cent'  =>                                              '162',
  27. 'pound' =>                                              '163',
  28. 'curren'        =>                                              '164',
  29. 'yen'   =>                                              '165',
  30. 'brvbar'        =>                                              '166',
  31. 'sect'  =>                                              '167',
  32. 'uml'   =>                                              '168',
  33. 'copy'  =>                                              '169',
  34. 'ordf'  =>                                              '170',
  35. 'laquo' =>                                              '171',
  36. 'not'   =>                                              '172',
  37. 'shy'   =>                                              '173',
  38. 'reg'   =>                                              '174',
  39. 'macr'  =>                                              '175',
  40. 'deg'   =>                                              '176',
  41. 'plusmn'        =>                                              '177',
  42. 'sup2'  =>                                              '178',
  43. 'sup3'  =>                                              '179',
  44. 'acute' =>                                              '180',
  45. 'micro' =>                                              '181',
  46. 'para'  =>                                              '182',
  47. 'middot'        =>                                              '183',
  48. 'cedil' =>                                              '184',
  49. 'sup1'  =>                                              '185',
  50. 'ordm'  =>                                              '186',
  51. 'raquo' =>                                              '187',
  52. 'frac14'        =>                                              '188',
  53. 'frac12'        =>                                              '189',
  54. 'frac34'        =>                                              '190',
  55. 'iquest'        =>                                              '191',
  56. 'Agrave'        =>                                              '192',
  57. 'Aacute'        =>                                              '193',
  58. 'Acirc' =>                                              '194',
  59. 'Atilde'        =>                                              '195',
  60. 'Auml'  =>                                              '196',
  61. 'Aring' =>                                              '197',
  62. 'AElig' =>                                              '198',
  63. );
  64.  
  65.  
  66. ;
  67. my $file = read_file("/tmp/xmls/$ARGV[0]");
  68. #my $dec = HTML::Entities::decode_entities($file);
  69. y $re = join '|',  rev_nsort_by { length($b) <=> length($a) } keys %entity2char; $file =~ s/($re)/$entity2char{$1}/g;
  70. #print utf8::encode($file);
  71. my $stingData =  $parser->parse_string( $file);
Add Comment
Please, Sign In to add comment