Sorting specific values from an XML file
Hi, all.
I need a shell script which gathers the data from a remote XML file and then displays it according to my needs.. I need this for my job due to the fact that I need to keep track price changes of euro, usd, gold, etc. The XML file I am talking about is located at this page: here. The reason I am posting the URL is that I need to use curl to get this file and it does NOT have newlines after each tag. I thought that that would be a problem. Here is what I need from the script: 1) curl to get the page 2) make use of sed, awk, etc. to display its contents in a more structured and readable manner as shown below: A: 64.125 (% -0.26) B: 81.130 (% -0.32) C: 1.4930 (% 0.00) D: 1.9590 (% 0.36) I am looking forward to your insights.. Thanks! |
Is there a particular reason you have to use BASH rather than a scripting language like perl, python, or ruby? All of these languages have mechanisms for parsing XML and grabbing webpage contents that making writing such a utility much easier.
I'm not saying it's not possible in BASH just that it would require more than a simple little script. Regards, Alunduil |
perl and python are also welcome. There is no specific reason that I prefer shell scripting over those languages.. I also think that it is a really tough job to accomplish this task under bash even though I do not know a little bit on programming :)
|
Code:
#!/usr/bin/env ruby -w Code:
$ ruby test.rb |
You could use xsltproc to transform the xml file according to your .xslt transform file.
Also, using 'xmllint --format' could reformat the xml file making it easier to use sed or awk if you wish to. |
Code:
curl -s http://cnnturk.com/finans/ticker/endeks.asp | |
All times are GMT -5. The time now is 08:33 AM. |