ASX parser module?

Discussion in 'Perl Misc' started by arz, May 14, 2007.

  1. arz

    arz Guest

    Hi,

    I need an ASX link checker script that parses ASX media description
    files and checks whether the resulting links point to valid media
    streams.

    Searching at CPAN, it seems that there are some modules available for
    creating ASX files, but not for parsing. So I was wondering is there
    anything specifically available for parsing ASX or do I just need to
    use any of the XML::* modules?

    XML::Simple would seem good enough with the least amount of code, only
    I guess the associative array will have case-insensitive keys, because
    the ASX is case-insensitive, so the values will not be directly
    addressable, and I'll have to iterate over the keys each time to find
    which case is used...

    Any other suggestion welcome.

    Thanks,
    Arnoud.
     
    arz, May 14, 2007
    #1
    1. Advertising

  2. On 14 May 2007 05:00:18 -0700, arz <> wrote:

    >Searching at CPAN, it seems that there are some modules available for
    >creating ASX files, but not for parsing. So I was wondering is there
    >anything specifically available for parsing ASX or do I just need to
    >use any of the XML::* modules?


    AIUI any XML parsing module would do.

    >XML::Simple would seem good enough with the least amount of code, only


    I second that.

    >I guess the associative array will have case-insensitive keys, because
    >the ASX is case-insensitive, so the values will not be directly
    >addressable, and I'll have to iterate over the keys each time to find
    >which case is used...


    Nope, keys are strings, and as such *are* case sensitive. You have to
    deal with ASX's case insensitiveness yourself. Doesn't seem a hard
    task.


    Michele
    --
    {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
    (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
    ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
    256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
     
    Michele Dondi, May 14, 2007
    #2
    1. Advertising

  3. On Mon, 14 May 2007 15:21:13 +0200, Christian Winter
    <> wrote:

    >Another relatively straight forward way would be with XML::TreeBuilder.
    >Instead of addressing hash keys you'd do something like


    Thanks, I have used H::T but didn't know X::T (although I may have
    guessed) and for all of my XML stuff, since I'm really a noob at that
    and don't have particular "performance" requirements, I use X::S. Now,
    this is of course good news!


    Michele
    --
    {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
    (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
    ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
    256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
     
    Michele Dondi, May 14, 2007
    #3
  4. arz

    arz Guest

    On 14 mei, 15:21, Christian Winter <> wrote:
    > arz wrote:
    > > I need an ASX link checker script that parses ASX media description
    > > files and checks whether the resulting links point to valid media
    > > streams.

    >
    > > Searching at CPAN, it seems that there are some modules available for
    > > creating ASX files, but not for parsing. So I was wondering is there
    > > anything specifically available for parsing ASX or do I just need to
    > > use any of the XML::* modules?

    >
    > > XML::Simple would seem good enough with the least amount of code, only
    > > I guess the associative array will have case-insensitive keys, because
    > > the ASX is case-insensitive, so the values will not be directly
    > > addressable, and I'll have to iterate over the keys each time to find
    > > which case is used...

    >
    > > Any other suggestion welcome.

    >
    > Another relatively straight forward way would be with XML::TreeBuilder.
    > Instead of addressing hash keys you'd do something like
    >
    > my $tree = XML::TreeBuilder->new;
    > $tree->parse_file('example.asx');
    >
    > for my $entry ( $tree->look_down('_tag', 'entry' ) )
    > {
    > my $ref = $entry->look_down('_tag', 'ref');
    > if( $ref && $ref->attr('href') && validstream( $ref->attr('href') ) )
    > ...
    >
    > }
    >
    > IMHO not too much typing overhead to get case-insensitive tag matching.
    >
    > -Chris


    Thanks! This looks like what I need. Now I only need case checking for
    'href' as an attribute, but all mixed-case tags are covered.
    Straightforward indeed.

    Arnoud.
     
    arz, May 14, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John

    webservice global.asx error

    John, Sep 22, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,014
  2. Bernd Oninger
    Replies:
    0
    Views:
    764
    Bernd Oninger
    Jun 9, 2004
  3. ZOCOR

    XML Parser VS HTML Parser

    ZOCOR, Oct 3, 2004, in forum: Java
    Replies:
    11
    Views:
    821
    Paul King
    Oct 5, 2004
  4. John

    webservice global.asx error

    John, Sep 22, 2004, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    185
    Sayed Hashimi
    Sep 24, 2004
  5. How to record .asx files

    , Apr 19, 2008, in forum: Perl Misc
    Replies:
    0
    Views:
    115
Loading...

Share This Page