WMW has asked for the wisdom of the Perl Monks concerning the following question:

The folowing works with XML::Smart 1.4.x but stops working with 1.5.x.

----------------------------------------------------------

my @output = @{$XML->{output}('name','eq',"$show"){frames}}; print "\n == Available Frame Formats For $show =="; foreach my $o (@output ){ print "\n $o->{format}"; }
----------------------------------------------------------

The 'Changes' log file says that from 1.5.0 'Multiple contents handled in different way.' but from what I've read in the docs I can't see why this would stop working.

Thanks
wmw

janitored by ybiC: Balanced <code> tags around codeblock

Replies are listed 'Best First'.
Re: XML::Smart 1.4.x vs 1.5.x
by samtregar (Abbot) on Apr 26, 2004 at 20:51 UTC
    Does it produce an error message? Maybe try looking at what the expression is returning before trying to dereference it:

    my $ref = $XML->{output}('name','eq',"$show"); use Data::Dumper; print Dumper($ref);

    Maybe what you see will make it obvious why your code isn't working.

    -sam

    PS: You might also consider finding another XML module. XML::Smart is interesting, but it's not exactly part of the Perl XML processing mainstream.

Re: XML::Smart 1.4.x vs 1.5.x
by gmpassos (Priest) on Apr 27, 2004 at 11:23 UTC
    Here this is working:
    use XML::Smart ; my $XML = new XML::Smart(q` <root> <output name='123'> <frames format='a'/> <frames format='b'/> </output> <output name='546'> <frames format='c'/> <frames format='d'/> </output> </root> `,'smart'); $XML = $XML->cut_root ; my $show = 123 ; my @output = @{ $XML->{output}('name','eq',$show){frames} } ; print "\n == Available Frame Formats For $show =="; foreach my $o (@output ){ print "\n $o->{format}" ; }
    Output:
    == Available Frame Formats For 123 == a b
    This was tested with XML::Smart/1.5.9.

    Graciliano M. P.
    "Creativity is the expression of the liberty".

      Ok this seems to be down to how I format my XML spec file.

      -- Current -----------------------------------------------
      <main>
      <output>
        <name>StdQT</name>
        <desc>Standard Quicktime</desc>
        <spec>320x240 using square pixels, no crop and 3D LUT.</spec>
        <frames name="FullAp" format="2048x1556">
          <script>...</script>
        </frames>
        <frames name="Vista" format="3072x2048">
          <script>...</script>
        </frames>
      </output>
      </main>

      This does not work, but if I format it like so;

      -- New ---------------------------------------------------
      <main>
      <output name="StdQT">
        <desc>Standard Quicktime</desc>
        <spec>320x240 using square pixels, no crop and 3D LUT.</spec>
        <frames name="FullAp" format="2048x1556">
          <script>...</script>
        </frames>
        <frames name="Vista" format="3072x2048">
          <script>...</script>
        </frames>
      </output>
      </main>

      This does work.

      Thanks
      wmw