XML::Writer and recursion are your friends here. A lot depends on how you want the XML to look. Here's an example where everything is an element. You could also just make the settings per Begin/End block attributes of an element identified by Begin. That got pretty ugly with so many elements so I did it this way. It'll at least get you started. I set the XML::Writer UNSAFE attribute to get it forced through. You'll want to define your XML so it's real and you can get rid of that ...

use strict; use XML::Writer; my $xml = XML::Writer->new(DATA_MODE => 1, DATA_INDENT => 4, UNSAFE => + 1); to_xml(); sub new_tag { my $tag = shift; $xml->startTag($tag); while (<DATA>) { chomp; if (/^\s*Begin\s+\S+\s+(\w+)\s*$/) { new_tag($1); } elsif (/^\s*End\s*$/) { $xml->endTag($tag); return; } elsif (/^\s*(\w+)\s*=\s*\"?(.+)\"?\s*$/) { $xml->startTag($1); $xml->characters($2); $xml->endTag($1); } } } sub to_xml { while (<DATA>) { chomp; new_tag($1) if (/^\s*Begin\s+\S+\s+(\w+)\s*$/); } } __DATA__ VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 6465 ClientLeft = 60 ClientTop = 345 ClientWidth = 11715 LinkTopic = "Form1" ScaleHeight = 6465 ScaleWidth = 11715 StartUpPosition = 3 'Windows Default Begin VB.Frame main_frame Caption = "Frame1" Height = 8775 Left = 0 TabIndex = 0 Top = 360 Width = 10695 Begin VB.TextBox sub_category_creator_text Height = 285 Left = 7320 TabIndex = 8 Top = 1680 Width = 1815 End Begin VB.TextBox category_creator_text Height = 285 Left = 2040 TabIndex = 6 Top = 1680 Width = 2295 End Begin VB.TextBox reference_number_text Height = 285 Left = 2040 TabIndex = 4 Top = 1200 Width = 2295 End Begin VB.TextBox title_text Height = 285 Left = 2040 TabIndex = 2 Top = 600 Width = 4695 End Begin VB.Image sub_category_picker_image Height = 375 Left = 9360 Top = 1680 Width = 375 End Begin VB.Label sub_category_creator Alignment = 1 'Right Justify Caption = "Sub Category (Creator)" Height = 375 Left = 5520 TabIndex = 7 Top = 1680 Width = 1695 End Begin VB.Image creator_picker_image Height = 375 Left = 4440 Top = 1680 Width = 375 End Begin VB.Label category_creator Alignment = 1 'Right Justify Caption = "Category (Creator)" Height = 375 Left = 360 TabIndex = 5 Top = 1680 Width = 1575 End Begin VB.Label reference_number Alignment = 1 'Right Justify Caption = "Reference Number" Height = 375 Left = 360 TabIndex = 3 Top = 1200 Width = 1575 End Begin VB.Label TitleLabel Alignment = 1 'Right Justify Caption = "Title*:" Height = 375 Left = 360 TabIndex = 1 Top = 600 Width = 1575 End End

Output looks like this:

<Form1> <Caption>Form1"</Caption> <ClientHeight>6465</ClientHeight> <ClientLeft>60</ClientLeft> <ClientTop>345</ClientTop> <ClientWidth>11715</ClientWidth> <LinkTopic>Form1"</LinkTopic> <ScaleHeight>6465</ScaleHeight> <ScaleWidth>11715</ScaleWidth> <StartUpPosition>3 'Windows Default</StartUpPosition> <main_frame> <Caption>Frame1"</Caption> <Height>8775</Height> <Left>0</Left> <TabIndex>0</TabIndex> <Top>360</Top> <Width>10695</Width> <sub_category_creator_text> <Height>285</Height> <Left>7320</Left> <TabIndex>8</TabIndex> <Top>1680</Top> <Width>1815</Width> </sub_category_creator_text> <category_creator_text> <Height>285</Height> <Left>2040</Left> <TabIndex>6</TabIndex> <Top>1680</Top> <Width>2295</Width> </category_creator_text> <reference_number_text> <Height>285</Height> <Left>2040</Left> <TabIndex>4</TabIndex> <Top>1200</Top> <Width>2295</Width> </reference_number_text> <title_text> <Height>285</Height> <Left>2040</Left> <TabIndex>2</TabIndex> <Top>600</Top> <Width>4695</Width> </title_text> <sub_category_picker_image> <Height>375</Height> <Left>9360</Left> <Top>1680</Top> <Width>375</Width> </sub_category_picker_image> <sub_category_creator> <Alignment>1 'Right Justify</Alignment> <Caption>Sub Category (Creator)"</Caption> <Height>375</Height> <Left>5520</Left> <TabIndex>7</TabIndex> <Top>1680</Top> <Width>1695</Width> </sub_category_creator> <creator_picker_image> <Height>375</Height> <Left>4440</Left> <Top>1680</Top> <Width>375</Width> </creator_picker_image> <category_creator> <Alignment>1 'Right Justify</Alignment> <Caption>Category (Creator)"</Caption> <Height>375</Height> <Left>360</Left> <TabIndex>5</TabIndex> <Top>1680</Top> <Width>1575</Width> </category_creator> <reference_number> <Alignment>1 'Right Justify</Alignment> <Caption>Reference Number"</Caption> <Height>375</Height> <Left>360</Left> <TabIndex>3</TabIndex> <Top>1200</Top> <Width>1575</Width> </reference_number> <TitleLabel> <Alignment>1 'Right Justify</Alignment> <Caption>Title*:"</Caption> <Height>375</Height> <Left>360</Left> <TabIndex>1</TabIndex> <Top>600</Top> <Width>1575</Width> </TitleLabel> </main_frame> </Form1>
</code>

In reply to Re: VB File to XML file by steves
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.