I am writing a shell script to extract only the error message from a log file.
I am having difficulty in searching the highlighted text in the below code.
<runtimeinfo datetime="Sun Apr 04 20:02:52 EDT 2008" docid="" source="RAWDATA" event="ERROR" xceError="com.lxnx.fab.ce.xce.tools.XCEValidateException:
com.lxnx.fab.ce.xce.tools.XCEValidateException: validateXML(): Data is not well formed. org.xml.sax.SAXParseException: The element type p must be terminated by the matching end-tag </p>."/>
</message>
<runtimeinfo datetime="Sun Apr 04 20:03:01 EDT 2008" docid="" source="DOC" event="ERROR" xceError="com.lxnx.fab.ce.xce.tools.XCEDocConversionException
: TransformEngine Raw data validation Exception: com.lxnx.fab.ce.xce.tools.XCEValidateException: com.lxnx.fab.ce.xce.tools.XCEValidateException:
::::1:411:410:The content of element type p must match (br|table|a|b|i) ."/>
</message>
<runtimeinfo datetime="Thu Apr 08 06:08:04 EDT 2008" docid="" source="RAWDATA" event="ERROR" xceError="com.lxnx.fab.ce.xce.tools.XCEValidateException: com.lxnx.fab.ce.xce.tools.XCEValidateException:
::::1:2307:2306:Element type tbody must be declared.
::::1:2595:2594:The content of element type table must match (nl).
::::1:3555:3554:Element type tbody must be declared.
::::1:3843:3842:The content of element type table must match (nl).
::::1:8456:8455:Element type tbody must be declared.
::::1:8744:8743:The content of element type table must match (nl)."/>
</message>
$
$
$ cat -n f5
1 <runtimeinfo datetime="Sun Apr 04 20:02:52 EDT 2008" docid="" source="RAWDATA" event="ERROR" xceError="com.lxnx.fab.ce.xce.tools.XCEValidateException:
2 com.lxnx.fab.ce.xce.tools.XCEValidateException: validateXML(): Data is not well formed. org.xml.sax.SAXParseException: The element type p must be terminated by the matching end-tag </p>."/>
3 </message>
4
5 <runtimeinfo datetime="Sun Apr 04 20:03:01 EDT 2008" docid="" source="DOC" event="ERROR" xceError="com.lxnx.fab.ce.xce.tools.XCEDocConversionException
6 : TransformEngine Raw data validation Exception: com.lxnx.fab.ce.xce.tools.XCEValidateException: com.lxnx.fab.ce.xce.tools.XCEValidateException:
7 ::::1:411:410:The content of element type p must match (br|table|a|b|i) ."/>
8 </message>
9
10 <runtimeinfo datetime="Thu Apr 08 06:08:04 EDT 2008" docid="" source="RAWDATA" event="ERROR" xceError="com.lxnx.fab.ce.xce.tools.XCEValidateException: com.lxnx.fab.ce.xce.tools.XCEValidateException:
11 ::::1:2307:2306:Element type tbody must be declared.
12 ::::1:2595:2594:The content of element type table must match (nl).
13 ::::1:3555:3554:Element type tbody must be declared.
14 ::::1:3843:3842:The content of element type table must match (nl).
15 ::::1:8456:8455:Element type tbody must be declared.
16 ::::1:8744:8743:The content of element type table must match (nl)."/>
17 </message>
$
$
$ perl -lne 'BEGIN{$/=""} while(/^<runtimeinfo.*Exception:[ \n:\d]+(.*)."\/>.*$/msg){print "\n==== Exception Message No. ",$i++," ====\n",$1}' f5
==== Exception Message No. 0 ====
The element type p must be terminated by the matching end-tag </p>
==== Exception Message No. 1 ====
The content of element type p must match (br|table|a|b|i)
==== Exception Message No. 2 ====
Element type tbody must be declared.
::::1:2595:2594:The content of element type table must match (nl).
::::1:3555:3554:Element type tbody must be declared.
::::1:3843:3842:The content of element type table must match (nl).
::::1:8456:8455:Element type tbody must be declared.
::::1:8744:8743:The content of element type table must match (nl)
$
$