help with complex bash script-XML handling
I need to write a script that will do the following:
The script will be called by an application while, at the same time, the application will create an xml file. After that, I want to process the xml file and derive only the text included by specific tags. Then, I want that text to be passed to another application that will make some automatic substitutions (this program can accept standard input or text files). After that, I want the changed text to return to its original position in the original xml.
This seems quite complex to me, but I would like some help with the logic and the steps I must follow. As I see it, I would have to assign the text I want to a global variable, which will then be passed to the 2nd application that will do the substitutions. Should I use a text editor (sth like sed maybe) to parse the xml and find the text? Are there any command line xml editors that will make the procedure easier?
Thanks in advance.
I would prefer to use a command line tool which is specialised in parsing xml, like xmlcatalog of xmllint - or to use Perl with a xml module.
You will not be happy trying to parse xml with sed & Co.
Concur with above.
I am half way to accomplish it -- more help please
You guys were absolutely right about using an xml command-line parser. After I gave up with grep, I found a fantastic program, xmlstarlet, that simplifies incredibly the task of extracting the text I want.
Now, I have found the way to put the modified text back to the xml file, but I need some advice about accessing the other application that will process it. The other application runs on another machine, my server, so I have to find a way to pass the text there and have it back modified to my desktop pc. One more challenge is that the remote program loads huge amount of data in memory when it is called, so I need that data to stay in memory otherwise the processing of the text is very time consuming. I was advised to use netpipes, hose and faucet, to establish a client-server communication. However, I can't find much documentation about this.
Any ideas are most welcome.
I think you (they) mean network (socket) programming, using the TCP protocol.
http://beej.us/guide/bgnet/ a guide in C.
Which lang are you comfortable with? Personally I use Perl, but most of the 'serious' langs have a socket lib or equiv.
|All times are GMT -5. The time now is 10:52 AM.|