-1

XML::Simple を使用して配列を解析しています。閉じるタグがあると確信している間、常に No Close タグ マーカーが表示されます...

配列から直接印刷した場合の出力は次のとおりです `

    <ClearQuest db='XXX' login='XXXX' cqtan='1319' client='XXX.com' ip=''>
   <defect id='dts0100' action='view' status='ok'>
     <component>RA_Checks</component>
     <description>Please, discuss before resolution.
 </description>
     <headline>[CSV] Got a warning </headline>
     <id_short>799</id_short>
     <owner>ABC</owner>
     <planned_release.name>2013</planned_release.name>
   </defect>
 </ClearQuest>

`

要素の終了タグは常に表示されません。Iam の解析方法は次のとおりです。

 my $a = join("",@cmdout);
   my $ref= XMLin($a);
   print $ref->{ClearQuest}->{defect}-{'id_short'};
   print $ref;

`

誰でもこのエラーで私を助けてくれますか!

print Dumper \@cmdout を使用すると、次のようになりました `

   $VAR1 = [
              '<ClearQuest db=\'d1\' login=\'\' cqtan=\'1\' client=\'dhcp-3\' ip=\'1\'>
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'dt\' login=\'\' cqtan=\'13\' client=\'dhcp-3\' ip=\'1\'>
    ',
              '  <defect id=\'dts0100\' action=\'view\' status=\'ok\'>
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'dt\' login=\'\' cqtan=\'1\' client=\'dhcp-3\' ip=\'1\'>
    ',
              '  <defect id=\'dts0100\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'d\' login=\'\' cqtan=\'1\' client=\'dhcp\' ip=\'137.202.34.85\'>
    ',
              '  <defect id=\'dts\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addresses for all my register instances
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'d\' login=\'\' cqtan=\'1\' client=\'dhcp-3\' ip=\'1\'>
    ',
              '  <defect id=\'dts0100\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addresses for all my register instances
    ',
              '
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'dt\' login=\'sh\' cqtan=\'13\' client=\'d\' ip=\'\'>
    ',
              '  <defect id=\'dts0100\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addresses for all my register instances,
    ',
              '
    ',
              'I believe no warning should be produced 
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'\' login=\'s\' cqtan=\'\' client=\'dhcp\' ip=\'1\'>
    ',
              '  <defect id=\'dts0100799428\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addresses for all my register instance
    ',
              '
    ',
              'I believe no warning should be produced 
    ',
              '
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'\' login=\'\' cqtan=\'\' client=\'dhcp-34-85.egc.mentorg.com\' ip=\'1\'>
    ',
              '  <defect id=\'dts\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addresses for all my register instances
    ',
              '
    ',
              'I believe no warning should be produced 
    ',
              '
    ',
              'Please, discuss before resolution.
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'d\' login=\'\' cqtan=\'13\' client=\'dhcp-34-\' ip=\'137\'>
    ',
              '  <defect id=\'dts01\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addresses for all my register instances
    ',
              '
    ',
              'I believe no warning should be produced
    ',
              '
    ',
              'Please, discuss before resolution.
    ',
              '</description>
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'dt\' login=\'s\' cqtan=\'131\' client=\'dhcp-34\' ip=\'13\'>
    ',
              '  <defect id=\'dts01\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addressed
    ',
              '
    ',
              'I believe no warning should be produced 
    ',
              '
    ',
              'Please, discuss before resolution.
    ',
              '</description>
    ',
              '    <headline>[CSV] Got a warning for a missing "Register Address" column.</headline>
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'d\' login=\'\' cqtan=\'130\' client=\'dhcp\' ip=\'13\'>
    ',
              '  <defect id=\'dts0100799428\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addresses fornot appear!
    ',
              '
    ',
              'I believe no warning should be produced when that column
    ',
              '
    ',
              'Please, discuss before resolution.
    ',
              '</description>
    ',
              '    <headline>[CSV] Got a warning for a missing "Register Address" column.</headline>
    ',
              '    <id_short>79</id_short>
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'dt1\' login=\\' cqtan=\'\' client=\'dhcp-34-85.egc.mentorg.com\' ip=\'1\'>
    ',
              '  <defect id=\'dts0\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addresses for all my register instances,
    ',
              '
    ',
              'I believe no warning should be produced 
    ',
              '
    ',
              'Please, discuss before resolution.
    ',
              '</description>
    ',
              '    <headline>[CSV] Got a warning for a missing "Register Address" column.</headline>
    ',
              '    <id_short></id_short>
    ',
              '    <owner>am</owner>
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'dts1\' login=\'\' cqtan=\'131\' client=\'dhcp\' ip=\'13\'>
    ',
              '  <defect id=\'dts01\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addresses for all my register instances
    ',
              '
    ',
              'I believe no warning should be produced
    ',
              '
    ',
              'Please, discuss before resolution.
    ',
              '</description>
    ',
              '    <headline>[CSV] Got a warning for a missing "Register Address" column.</headline>
    ',
              '    <id_short>799428</id_short>
    ',
              '    <owner>am</owner>
    ',
              '    <planned_release.name>2013.1</planned_release.name>
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'dt\' login=\'\' cqtan=\'\' client=\'dhcp-3\' ip=\'13\'>
    ',
              '  <defect id=\'dts0\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addresses for all my register instances
    ',
              '
    ',
              'I believe no warning should be produced 
    ',
              '
    ',
              'Please, discuss before resolution.
    ',
              '</description>
    ',
              '    <headline>[CSV] Got a warning for a missing "Register Address" column.</headline>
    ',
              '    <id_short></id_short>
    ',
              '    <owner></owner>
    ',
              '    <planned_release.name>2013.1</planned_release.name>
    ',
              '  </defect>
    '
            ];
    $VAR1 = [
              '<ClearQuest db=\'dts01\' login=\'\' cqtan=\'\' client=\'dhcp-34-...com\' ip=\'1\'>
    ',
              '  <defect id=\'dts010\' action=\'view\' status=\'ok\'>
    ',
              '    <component>RA_Checks</component>
    ',
              '    <description>I have specified addresses for all my register instances
    ',
              '
    ',
              'I believe no warning should be produced 
    ',
              '          '    <id_short>798</id_short>
    ',
              '    <owner>a</owner>
    ',
              '    <planned_release.name>2013.1</planned_release.name>
    ',
              '  </defect>
    ',
              '</ClearQuest>'
            ];

`

4

2 に答える 2

2

XML::SimpleXML の解析には不適切な選択です。使用するのは「簡単」とはほど遠い可能性があり、独自のドキュメントにはこれが記載されています。

新しいコードでこのモジュールを使用することはお勧めできません。より直接的で一貫したインターフェースを提供する他のモジュールが利用可能です。

ただし、不正な XML を検出する能力は十分にあり、表示されるデータは問題ありません。処理のためにそのリテラル テキストを に渡してもXMLin、エラーは発生しません。

したがって、あなたが渡しているデータは、あなたが思っているものではありません。配列をよく見ることをお勧めします

use Data::Dumper;
print Dumper \@cmdout;

それでも問題を解決できない場合は、その出力をここに投稿してください。

于 2013-07-14T13:01:38.857 に答える
-1

必要なもの:

$ref->{defect}->{'id_short'};
于 2013-07-14T13:00:58.943 に答える