RE: [newbie] xml and grep

2004-03-23 Thread Tony S. Sykes
Thanks everyone I will be putting this into practice asap to save my fingers.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Carl J. Bauman
Sent: Tuesday, March 23, 2004 12:13 AM
To: [EMAIL PROTECTED]
Subject: Re: [newbie] xml and grep


[EMAIL PROTECTED] wrote:

>On Mon, Mar 22, 2004 at 02:53:50PM +, 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.
>>
>>
>
>So, assuming the xml fax line was something like
>
>123-456-7890
>
>  
>

Assuming the same tags as above, this would probably work also:

cat fax.xml | perl -n -e ' print "$1\n" if /(.+)<\/fax>/; '

HTH,
Carl




-+-+-+-+-+-+-+-+-+ Business Computer Projects - Disclaimer -+-+-+-+-+-+-+-+-+-
This message, and any associated attachment is confidential.  If you have recieved
it in error, please delete it from your system, do not use or disclose the information
in any way, and notify either the sender or [EMAIL PROTECTED] immediately.
The contents of this message may contain personal views which are not necessarily 
the views of Business Computer Projects Ltd., unless specifically stated.  Whilst every
effort has been made to ensure that emails and their attachments are virus free, it is 
the responsibility of the recipient(s) to verify the integrity of such emails.
Business Computer Projects Ltd
BCP House
151 Charles Street
Stockport
Cheshire
SK1 3JY
Tel: +44 (0)161 355-3000
Fax: +44 (0)161 355-3001
Web: http://www.bcpsoftware.com

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Join the Club : http://www.mandrakeclub.com


Re: [newbie] xml and grep

2004-03-22 Thread Carl J. Bauman
[EMAIL PROTECTED] wrote:

On Mon, Mar 22, 2004 at 02:53:50PM +, 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.
   

So, assuming the xml fax line was something like

123-456-7890

 

Assuming the same tags as above, this would probably work also:

   cat fax.xml | perl -n -e ' print "$1\n" if /(.+)<\/fax>/; '

HTH,
Carl

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Join the Club : http://www.mandrakeclub.com


Re: [newbie] xml and grep

2004-03-22 Thread Todd Slater
On Mon, Mar 22, 2004 at 02:53:50PM +, 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'/g > processed

The "\n" gives you a new line, so I'm saying every time you see "" replace it
with "/a>\n"

So, assuming the xml fax line was something like

123-456-7890

you could do

sed s/''/'\n'/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


Re: [newbie] xml and grep

2004-03-22 Thread Marc Lijour
Here is the complete scenario:

urpmi libxslt-proc

[EMAIL PROTECTED] xmlTest]$ xsltproc trans.xsl test.xml
[EMAIL PROTECTED] xmlTest]$


It should work regardless of the position of the fax element (or rename it
as necessary).

> 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.

I do not know about cut &co (that should be possible). But the real tool
for the job is a XSLT processor!

urpmi libxslt
(urpmi libxml2 too?)

xsltproc
(read the options)


The xsl file should look like this:
---


  




>
> -+-+-+-+-+-+-+-+-+ Business Computer Projects - Disclaimer
> -+-+-+-+-+-+-+-+-+- This message, and any associated attachment is
> confidential.  If you have recieved it in error, please delete it from
> your system, do not use or disclose the information in any way, and
> notify either the sender or [EMAIL PROTECTED] immediately. The
> contents of this message may contain personal views which are not
> necessarily  the views of Business Computer Projects Ltd., unless
> specifically stated.  Whilst every effort has been made to ensure that
> emails and their attachments are virus free, it is  the responsibility
> of the recipient(s) to verify the integrity of such emails. Business
> Computer Projects Ltd
> BCP House
> 151 Charles Street
> Stockport
> Cheshire
> SK1 3JY
> Tel: +44 (0)161 355-3000
> Fax: +44 (0)161 355-3001
> Web: http://www.bcpsoftware.com



http://www.w3.org/1999/XSL/Transform";>






  





	
	23


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Join the Club : http://www.mandrakeclub.com


Re: [newbie] xml and grep

2004-03-22 Thread Marc Lijour
> 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.

I do not know about cut &co (that should be possible). But the real tool
for the job is a XSLT processor!

urpmi libxslt
(urpmi libxml2 too?)

xsltproc
(read the options)


The xsl file should look like this:
---


  




>
> -+-+-+-+-+-+-+-+-+ Business Computer Projects - Disclaimer
> -+-+-+-+-+-+-+-+-+- This message, and any associated attachment is
> confidential.  If you have recieved it in error, please delete it from
> your system, do not use or disclose the information in any way, and
> notify either the sender or [EMAIL PROTECTED] immediately. The
> contents of this message may contain personal views which are not
> necessarily  the views of Business Computer Projects Ltd., unless
> specifically stated.  Whilst every effort has been made to ensure that
> emails and their attachments are virus free, it is  the responsibility
> of the recipient(s) to verify the integrity of such emails. Business
> Computer Projects Ltd
> BCP House
> 151 Charles Street
> Stockport
> Cheshire
> SK1 3JY
> Tel: +44 (0)161 355-3000
> Fax: +44 (0)161 355-3001
> Web: http://www.bcpsoftware.com




Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Join the Club : http://www.mandrakeclub.com


[newbie] xml and grep

2004-03-22 Thread Tony S. Sykes
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.


-+-+-+-+-+-+-+-+-+ Business Computer Projects - Disclaimer -+-+-+-+-+-+-+-+-+-
This message, and any associated attachment is confidential.  If you have recieved
it in error, please delete it from your system, do not use or disclose the information
in any way, and notify either the sender or [EMAIL PROTECTED] immediately.
The contents of this message may contain personal views which are not necessarily 
the views of Business Computer Projects Ltd., unless specifically stated.  Whilst every
effort has been made to ensure that emails and their attachments are virus free, it is 
the responsibility of the recipient(s) to verify the integrity of such emails.
Business Computer Projects Ltd
BCP House
151 Charles Street
Stockport
Cheshire
SK1 3JY
Tel: +44 (0)161 355-3000
Fax: +44 (0)161 355-3001
Web: http://www.bcpsoftware.com

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Join the Club : http://www.mandrakeclub.com


[newbie] xml and grep

2004-03-22 Thread Tony S. Sykes
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.


-+-+-+-+-+-+-+-+-+ Business Computer Projects - Disclaimer -+-+-+-+-+-+-+-+-+-
This message, and any associated attachment is confidential.  If you have recieved
it in error, please delete it from your system, do not use or disclose the information
in any way, and notify either the sender or [EMAIL PROTECTED] immediately.
The contents of this message may contain personal views which are not necessarily 
the views of Business Computer Projects Ltd., unless specifically stated.  Whilst every
effort has been made to ensure that emails and their attachments are virus free, it is 
the responsibility of the recipient(s) to verify the integrity of such emails.
Business Computer Projects Ltd
BCP House
151 Charles Street
Stockport
Cheshire
SK1 3JY
Tel: +44 (0)161 355-3000
Fax: +44 (0)161 355-3001
Web: http://www.bcpsoftware.com

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Join the Club : http://www.mandrakeclub.com