Report generation based on certain conditions

Hi I recently joined a project where I have been asked to generate a report using shell script accessing UNIX box.
I have no idea on how to do it as I am a beginner and learning shell scripts.

Suppose I have a XML:

Code:

<XYZRequest><effectiveDate>someDate</effectiveDate><expiryDate>someDate</expiryDate><reason>blahblah</reason>.....</XYZRequest>

This XML will be in one of the logs. I need to search for the element XYZ in logs and then check inside the XML for effectiveDate in the past and expiryDate as currentDate and if the condition succeeds check for the response <XYZResponse> in the logs and check if there is any error inside the elements say for example

<XYZResponse><Solution>Error</Solution></XYZResponse>.

If there is any entry in logs with Error, generate a report with the details if not generate a report saying no issues. Can someone pls help me.:wall:

A more generalized example will help us to understand better.

Example with dates etc.

Hi - I cant think of generalizing this further.

If your data contains newlines, you may be able to extract lines that contain your search criteria with grep, then do more processing on what is returned. It might also help to use

grep -A

or

grep -B

to get 1 or 2 lines before or after the search text.