[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] perl解析singer.xml报错

<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/"
xmlns:vlc="http://www.videolan.org/vlc/playlist/ns/0/">
        <title>歌手姓名</title>
        <trackList>
                   <track>
                                <album>Winnie Ho - Finally Chapter 01 (2016)
/</album>
                                <title>01 - Me and Myself.mp3</title>
                                <location>位置1</location>
                                <duration>172000</duration>
                   </track>
                   <track>
                                <album>Winnie Ho - Finally Chapter 01 (2016)
/</album>
                                <title>02 - Keep in Touch.mp3</title>
                                <location>位置2</location>
                                <duration>200000</duration>
                   </track>
                   <track>
                                <album>Winnie Ho - Finally Chapter 01 (2016)
/</album>
                                <title>03 - Missing.mp3</title>
                                <location>位置3</location>
                                <duration>207000</duration>
                   </track>
         </trackList>
</playlist>

=================

1楼是singer.xml

回复 1# netdzb

use strict;
use warnings;

use XML::Simple;
use Data:: Dumper;

use 5.010;
my $xmlfile = "singer.xml";
my $xml = XML::Simple->new(KeyAttr=>"", ForceArray => 1);

my $tree = $xml->XMLin($xmlfile);
say Dumper($tree);

TOP

直接复制执行后没有报错也
  1. $VAR1 = {
  2.           'title' => [
  3.                      "\x{6b4c}\x{624b}\x{59d3}\x{540d}"
  4.                    ],
  5.           'xmlns:vlc' => 'http://www.videolan.org/vlc/playlist/ns/0/',
  6.           'xmlns' => 'http://xspf.org/ns/0/',
  7.           'version' => '1',
  8.           'trackList' => [
  9.                          {
  10.                            'track' => [
  11.                                       {
  12.                                         'duration' => [
  13.                                                       '172000'
  14.                                                     ],
  15.                                         'location' => [
  16.                                                       "\x{4f4d}\x{7f6e}1"
  17.                                                     ],
  18.                                         'album' => [
  19.                                                    'Winnie Ho - Finally Chapter 01 (2016)
  20. /'
  21.                                                  ],
  22.                                         'title' => [
  23.                                                    '01 - Me and Myself.mp3'
  24.                                                  ]
  25.                                       },
  26.                                       {
  27.                                         'title' => [
  28.                                                    '02 - Keep in Touch.mp3'
  29.                                                  ],
  30.                                         'album' => [
  31.                                                    'Winnie Ho - Finally Chapter 01 (2016)
  32. /'
  33.                                                  ],
  34.                                         'duration' => [
  35.                                                       '200000'
  36.                                                     ],
  37.                                         'location' => [
  38.                                                       "\x{4f4d}\x{7f6e}2"
  39.                                                     ]
  40.                                       },
  41.                                       {
  42.                                         'location' => [
  43.                                                       "\x{4f4d}\x{7f6e}3"
  44.                                                     ],
  45.                                         'duration' => [
  46.                                                       '207000'
  47.                                                     ],
  48.                                         'album' => [
  49.                                                    'Winnie Ho - Finally Chapter 01 (2016)
  50. /'
  51.                                                  ],
  52.                                         'title' => [
  53.                                                    '03 - Missing.mp3'
  54.                                                  ]
  55.                                       }
  56.                                     ]
  57.                          }
  58.                        ]
  59.         };
复制代码
主要看报错说的啥。

TOP

返回列表