A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: XML and Perl

  1. #1
    Junior Member
    Join Date
    May 2001
    Posts
    3
    HI, i am really new to XML.
    I know how XML works by using parent and child tags
    ie:
    {parent}
    {child}value{/child}
    {/parent}

    and i want to get the value of the child and asign it to a string. to do that i must open the load the local file
    and take the value by using this method:
    Code:
    ($child) = <XMLFILE>=~ /\<child\>(.*)\<\/child\>/;
    ok thats how i can get the value of the child.
    my question is how can i get the value of the child and name of parent:

    {parent name="sam"}
    {child}value{/child}
    {/parent}

    *note please replace {} with <>, this board somehow wont display xml code

    [Edited by Do5 on 06-03-2001 at 01:21 PM]

  2. #2
    Junior Member
    Join Date
    Apr 2001
    Posts
    23
    &lt;parent name="sam">
    &lt;child>value&lt;/child>
    &lt;/parent>

    Code:
    ($child) = &lt;XMLFILE>=~ /\&lt;child\>(.*)\&lt;\/child\>/;
    well you could
    use XML::Parser;

    or, but only for this very specific document
    Code:
    while (&lt;XMLFILE>=~ ) {
    if ($_ =~ /\&lt;child\>(.*)\&lt;\/child\>/) {
        $child = $1;
    }
    if ($_ =~ /\&lt;parent\s.*name="(.*?)"/) {
         $parentName= $1;
    }
    }
    this is untested code.

  3. #3
    Junior Member
    Join Date
    May 2001
    Posts
    3

    Thanks

    Thanks
    i must of mistype my question;
    ok thats how i can get the value of the child.
    my question is how can i get the value of the child and name of parent:

    {parent name="sam"}
    {child}value{/child}
    {/parent}
    but heres half of the question i how would how can i get the value of the child by the name of parent
    {parent name="sam"}
    {child}michael{/child}
    {/parent}
    {parent name="jon"}
    {child}lisa{/child}
    {/parent}



    [Edited by Do5 on 06-05-2001 at 03:47 PM]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center