Capturing string between a xml tag

Hi All,
I have an XML-:

       <ProcId>CES_P5010_AddVLan</ProcId>
        <DataVersion>yxcxycyxcycyxc</DataVersion>
        <JobId>OR3000055-002-1</JobId>
          </CesHeader>
    <VLanServiceList>
        <NopId>blu</NopId>
    </VLanServiceList>
            <StatusNPA>2</StatusNPA>
        <ErrorTextNPA>Exception occurred trying to create Management Service :Exception occurred trying to create Service :Error Code=239023  [Virtual LAN: ].. ** </ErrorTextNPA>
    </NPAErrorHandling>
</CesResponse>

Here I want to have a shell script to get the string in the tag <ErrorTextNPA>*****<ErrorTextNPA>. Can any one help me on this.
Regards
Amit

Is this a single long line, or spanning over multiple lines?

As such, the following doesn't really care.

perl -0777 -pe 's%.*<ErrorTextNPA>%%s;s%</ErrorTextNPA>.*%%s' file

moved the thread from solaris to shell scripting for this is not a solris specific question...

using sed,

cat filename | grep -e '<ErrorTextNPA>' | sed 's/<ErrorTextNPA>\(.*\)<\/ErrorTextNPA>/\1/'
Thanks
Penchal

Actually the cat and grep are redundant.

sed -n 's%.*<ErrorTextNPA>\(.*\)</ErrorTextNPA>.*%\1%p' file.xml

However, it won't work if the open and close tags are on different lines. (There are ways to cope with that in sed, too, of course.)

The best way to handle this type of problem is to use an XSLT processor together with an XSL stylesheet to transform the XML document into whatever output you want - in this case the contents of the XML element <ErrorTextNPA>. UNIX command line tool such as awk, sed, etc were never designed to efficiently handle XML documents.

I would note that this is not possible for the supplied XML document since it is not a well-formed or valid XML document (missing root, missing opening tags, etc.)