Hi, I create one XML file which has certain steps of testcases.

<?xml version='1.0'?> <config> <Testcaseid step1="MTPconfiguration.pl" step2="MTPCheckState.pl" step3 +="TM500_RCI.py" step4="ParseTM500Logs.pl" step5="ParseMTPlogs.pl" /> <Testcaseid step1="MTPconfiguration.pl" step2="MTPcheckstateATTN.pl" s +tep3="TM500_RCI.py" step4="ParseTM500log.pl" step5="ParseMTPlogs.pl" +/> </config>

Now i want to read those steps in perl file in a loop. I am trying like the code which i mentioned below. But the problem is as the steps are storing as a hash, i am not able to access in order. for example, 1st it should print in the order as step1, step2, step3...so on but it is printing as step2, step1, step3, step5,step4.... if the content in xml file is written in text file, i am not able to access those values from the text file in perl file. Any help would be appreciated. Thanks in advance

use strict; use warnings; use XML::Simple; use Data::Dumper; my $XML = XMLin("C:\\Users\\Administrator\\Desktop\\Sample\\VERSION2\\ +testcase.xml"); my $testcaseid=$XML->{Testcaseid}; print Dumper(\$testcaseid); my ($testcase,$teststep,$key,$steps); while (($testcase,$teststep)=each @{$testcaseid}){ foreach my $steps (values %{$teststep}) { print "$steps\n"; } }

In reply to How to get the values from XML/Text file in a specific order? by vasuperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.