Sponsored Content
Top Forums Shell Programming and Scripting Generate a XML file from a text file Post 302359524 by jacki on Tuesday 6th of October 2009 09:17:27 PM
Old 10-06-2009
Generate a XML file from a text file

FILE-1
Code:
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 -
Code:
 <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

Last edited by pludi; 10-07-2009 at 03:12 AM.. Reason: code tags, please
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Plz Help To convert xml file to text file using bourn shell scripts

If someone out there could help me out with this problem. I would really appreciate it. I am trying to convert xml into text file(fixed length) using Unix Borne shell scripts. My xml file: <root> <header_rec recordtype="00"> <record_id>00</record_id> <country_code>AK></country_code>... (0 Replies)
Discussion started by: ram2s2001
0 Replies

2. Shell Programming and Scripting

generate new string from a text file

Hi, I have a file and the content looks like this: line1 line2 File #5 : found '/u01/testing.txt' line5 line6 line7 File #12 : found '/u01/testabc.txt' line10 line11 I want to write a bash script to give me the output: The file 5 is '/u01/testing.txt' The file 12 is... (6 Replies)
Discussion started by: walterwaston
6 Replies

3. UNIX for Dummies Questions & Answers

Script to generate text file from excel file

Hello, I have a excel file which has almost ten columns on the shared drive. I have to write a shell script to ftp that daily to unix server and then extract some columns from there and generate oracle standard text file. The columns should be in proper order and aligned properly, otherwise... (1 Reply)
Discussion started by: isingh786
1 Replies

4. Programming

Generate XML file from C++

Hi, I need to generate an XML file as output for a C++ program. Immediate idea that came across to me was through fprintf by mentioning all the attribute names/fields in the XML file one by one and inserting the values there which I get from C++ program. Is there any other better way to... (2 Replies)
Discussion started by: debu
2 Replies

5. Shell Programming and Scripting

KSH - help needed for creating a script to generate xml file from text file

Dear Members, I have a table in Oracle DB and one of its column name is INFO which has data in text format which we need to fetch in a script and create an xml file of a new table from the input. The contents of a single cell of INFO column is like: Area:app - aam Clean Up Criteria:... (0 Replies)
Discussion started by: Yoodit
0 Replies

6. Shell Programming and Scripting

Filter a .kml file (xml) with data set from text file

I have a .kml file. So I want filter the .kml to get only the tags that have this numeric codes that they are in a text file 11951 11952 74014 11964 11965 11969 11970 11971 11972 60149 74018 74023 86378 11976 11980 11983 11984 11987 (5 Replies)
Discussion started by: pcoj33
5 Replies

7. Programming

How to write a java program that will parse through an XML file and generate a report?

I'm pretty new to Java and I am trying to write a program that will pick up a file from a windows directory adn parse through the XML file to produce a report that will show a total item count and a total paid amount. Any one have any suggestions? Trying to figure out where to start... (4 Replies)
Discussion started by: risarose87
4 Replies

8. Shell Programming and Scripting

Generate .csv file a text file

Hi guys, I have a text file that states: cat prod.hosts 11.29.130.14 host1 host1.test.com web17 11.29.130.15 host2 host2.test.com web18 11.29.130.16 host3 host3.test.com web19 I want a .csv file that states: ... (2 Replies)
Discussion started by: Junaid Subhani
2 Replies

9. UNIX for Dummies Questions & Answers

Reading Xml file and print the values into the text file in columnwise?

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (4 Replies)
Discussion started by: sravanreddy
4 Replies

10. Programming

How to write in other language in text/xml file by reading english text/xml file using C++?

Hello Team, I have 2 files.one contains english text and another contains Japanese. so i have to read english text and replace the text with Japanesh text in third file. Basically, I need a help to write japanese language in text/xml file.I heard wstring does this.Not sure how do i write... (2 Replies)
Discussion started by: SA_Palani
2 Replies
GIT-DIFFTOOL(1) 						    Git Manual							   GIT-DIFFTOOL(1)

NAME
git-difftool - Show changes using common diff tools SYNOPSIS
git difftool [<options>] [<commit> [<commit>]] [--] [<path>...] DESCRIPTION
git difftool is a git command that allows you to compare and edit files between revisions using common diff tools. git difftool is a frontend to git diff and accepts the same options and arguments. See git-diff(1). OPTIONS
-y, --no-prompt Do not prompt before launching a diff tool. --prompt Prompt before each invocation of the diff tool. This is the default behaviour; the option is provided to override any configuration settings. -t <tool>, --tool=<tool> Use the diff tool specified by <tool>. Valid diff tools are: araxis, bc3, deltawalker, diffuse, emerge, ecmerge, gvimdiff, kdiff3, kompare, meld, opendiff, p4merge, tkdiff, vimdiff and xxdiff. If a diff tool is not specified, git difftool will use the configuration variable diff.tool. If the configuration variable diff.tool is not set, git difftool will pick a suitable default. You can explicitly provide a full path to the tool by setting the configuration variable difftool.<tool>.path. For example, you can configure the absolute path to kdiff3 by setting difftool.kdiff3.path. Otherwise, git difftool assumes the tool is available in PATH. Instead of running one of the known diff tools, git difftool can be customized to run an alternative program by specifying the command line to invoke in a configuration variable difftool.<tool>.cmd. When git difftool is invoked with this tool (either through the -t or --tool option or the diff.tool configuration variable) the configured command line will be invoked with the following variables available: $LOCAL is set to the name of the temporary file containing the contents of the diff pre-image and $REMOTE is set to the name of the temporary file containing the contents of the diff post-image. $MERGED is the name of the file which is being compared. $BASE is provided for compatibility with custom merge tool commands and has the same value as $MERGED. -x <command>, --extcmd=<command> Specify a custom command for viewing diffs. git-difftool ignores the configured defaults and runs $command $LOCAL $REMOTE when this option is specified. Additionally, $BASE is set in the environment. -g, --gui When git-difftool is invoked with the -g or --gui option the default diff tool will be read from the configured diff.guitool variable instead of diff.tool. See git-diff(1) for the full list of supported options. CONFIG VARIABLES
git difftool falls back to git mergetool config variables when the difftool equivalents have not been defined. diff.tool The default diff tool to use. diff.guitool The default diff tool to use when --gui is specified. difftool.<tool>.path Override the path for the given tool. This is useful in case your tool is not in the PATH. difftool.<tool>.cmd Specify the command to invoke the specified diff tool. See the --tool=<tool> option above for more details. difftool.prompt Prompt before each invocation of the diff tool. SEE ALSO
git-diff(1) Show changes between commits, commit and working tree, etc git-mergetool(1) Run merge conflict resolution tools to resolve merge conflicts git-config(1) Get and set repository or global options GIT
Part of the git(1) suite Git 1.7.10.4 11/24/2012 GIT-DIFFTOOL(1)
All times are GMT -4. The time now is 09:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy