regex in xml file

I have a huge xml file in  below format.
I want to search for particular string in line 1 and line2 of each <info>tag and create output xml which matched only my string.
I would like to know which scripting Lang/logic will be good for such operation.

Xml format.

<head>
<info1>
<line1>....</line1>
<line2>....</line2>
</info2>
.....
.....
<info1000>
<line1>....</line1>
<line2>....</line2>
</info1000>
</head>
rsvijayAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gertone (Geert Bormans)Information ArchitectCommented:
I could strongly suggest XPath2.0 (either from Java or from XSLT2)
XPath gives you the context: line1and line2 in a infonn element
version two of XPath gives you regular expression support inside the element content
I would drive this from a simple XSLT2 stylesheet
(one I could easily write for you if you need to)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gertone (Geert Bormans)Information ArchitectCommented:
If huge where over 100 MByte, you might want to consider a XSLT3 streaming approach
or write a SAX filter tpo go through the file
(not sure what you consider "huge")
rsvijayAuthor Commented:
Thanks Geert. Yes the source is 1GB+.  xpath and XSLT is new to me I will explore it.
How ever, can it done via UNIX scripting, perl..etc?
Gertone (Geert Bormans)Information ArchitectCommented:
The problem with unix scripting is that you don't treath the XML as XML,
so you need to keep track of your XML context yourself
and you might run into character encoding issues
If the encoding is reliable and the structure predictable, you might get away with line parsing

Anyhow, I advice you to at least parse the XML
Perl has some streaming XML parsing capabilities
http://search.cpan.org/~reatmon/XML-Stream-1.22/lib/XML/Stream.pm
it might be a bit complex for what you need however
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.