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

<xsl:apply-templates select="fax">
  <xsl:value-of select="."/>
</xsl:apply-templates>

------------------------

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


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
        <xsl:output method="text"/>
        <xsl:template match="/">
                <xsl:apply-templates select="//fax"/>
        </xsl:template>
        
<xsl:template match="fax">
  <xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0"?>

<doc>
	<data>....</data>
	<fax>23</fax>
</doc>

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