On Mon, Mar 22, 2004 at 02:53:50PM +0000, Tony S. Sykes wrote:
> Help, I have my web limited by my company now, so I can't google till tomorrow. I 
> need help with parsing an xml file. I need to cut out a fax number from the file. 
> Easy enough I though just grep and cut the line, but the whole file is one line. I 
> know this is a simple command but I can't work it out on my own, and with out google 
> (strange how easy you get attached to things) I am stuck. Please help.
> 
> Thanks,
> 
> Tony.

Tony,

Not sure if this'll help, but here's what I used to get all links to
begin on a new line.

sed s/'<a'/'\n<a'/g index.html | sed s/'\/a>'/'\/a>\n'/g > processed

The "\n" gives you a new line, so I'm saying every time you see "<a" replace
it with "\n<a" (starts on new line) and everytime you see "/a>" replace it
with "/a>\n"

So, assuming the xml fax line was something like

<fax>123-456-7890</fax>

you could do

sed s/'<fax>'/'\n<fax>'/g file_with_fax_number.xml | sed s/'<\/fax>'/'<\/fax>\n'/g > 
some_output_file

Then, you could grep some_output_file for "fax" or of course get fancy
and cut a certain number of characters to pull out just the fax number.

HTH,
Todd

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com
____________________________________________________
Join the Club : http://www.mandrakeclub.com

Reply via email to