Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select & Insert

Status
Not open for further replies.

jlguirao

Programmer
Nov 15, 2000
7
0
0
ES
Hello,

I want to make a script that given a <tag1> finds all the lines between <tag1> and </tag1> on a xml file and inserts this string after another </tag2> of another given xml file.

In other words: find a string between <tag1> & </tag1> on file1 and insert it into file2 after </tag2>.


Any ideas?


Thanks in advance.





 
Hi jlguirao,

Do you have Perl available to you?
Mike
michael.j.lacey@ntlworld.com
 
I haven't Perl. I need to make it with a Unix script.
 
Perl is available for all versions of Unix -- if you don't have it, or it's not worth getting just for this, then [tt]awk[/tt] will do the job, but I don't know enough awk to help you.....

Anybody else?
Mike
michael.j.lacey@ntlworld.com
 
It's not that easy, but if you want to use awk...
At first you need to match the string containing your tags. I suggest using 'grep'. The output of grep can be filtered by awk, you need the split-function implemented in all awks.
Syntax: split(<this_string>, <array>,<regexp>)
Regexp here would be something like: [\<?<tag\>]. After that you'll have the string in your array and you can read it out by using <array>[0 .. x].
That's some work, but if you make it -let me know!
regards
chenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top