You can keep a stack of contexts. Loop through line by line. Every time you find a begin line, push the name of the tag onto the stack and print the tag. (Keep an indent counter as well so that you can make pretty XML code).
Every time you find an end line. print the close tag for the top of the stack then pop the stack.
Any other line just prints itself as a tag:
my @stack; my $ind=0; while (<LINES>) { if (/^\s*Begin\s+(\w+)\s+(\w+)$/) { print (' ' x $ind) . "<$1 name='$2'>\n"; push @stack,$1; $ind += 3; } elsif (/^\s*End\s*/) { $ind -= 3; print (' ' x $ind) . "<" . (pop @stack) . ">\n"; } else { print (' ' x $ind) . "<$_>\n"; # change to print tag however y +ou want } }


My machine is going haywire and won't cut and paste, or print, or open any new windows, so I can't really test this, but the algorithm is sound. You'll probably want to add error checking and such.
Good Luck,

-pete
Entropy is not what is used to be.

Added ".frm" to title 2002-02-14 dvergin


In reply to Re: VB .frm File to XML file by dreadpiratepeter
in thread VB .frm File to XML file by nagesh

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.