Generate a XML file from a text file

FILE-1

USER  	username@foo.com
TOOLIN  	tool-a
TOOL2	tool-b
TOOL3	tool-c
TOOL4	tool-d
TOOL5	tool-e
USER	username_2@foo.com
TOOLIN  	tool-e
TOOL2	tool-f
TOOL3	tool-c
TOOL4	tool-d
 ....

I need to take this file and generate a target XML file -

 <access>
      <managed>
      <!-- Admin Servlet names listed here have access controls enforced -->
         <tool>tool-a</tool>
         <tool>tool-b</tool>
         <tool>tool-c</tool>
         <tool>tool-d</tool>
         <tool>tool-e</tool>
         <tool>tool-f</tool>
      </managed>
      <users>
         <user name="username@foo.com">
            <tools>
             <tool>tool-a</tool>
             <tool>tool-b</tool> 
             <tool>tool-c</tool>
             <tool>tool-d</tool>
             <tool>tool-e</tool>
            </tools>
         </user>
         <user name="username_2@foo.com">
           <tools>
             <tool>tool-e</tool>
             <tool>tool-f</tool> 
             <tool>tool-c</tool>
             <tool>tool-d</tool>
           </tools>
         </user>
 </users>
 </access>

Since I am new to scripting please suggest a script which can do that...

Thanks,
Jack

Please use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Thank You.

The UNIX and Linux Forums

You can use some perl modules to do that, such as XML::Quick - search.cpan.org or some other XML related modules.

Have a look at XI (XML Import)