Several options are open:
- Painstakingly go through your xml-file with a regex on a line-by-line basis, selecting everyting between <name></name>-tags and pushing this into an array and finally outputting the array between a <names></names> tag.
This may work, but is considered prone to breaking if your xml-file spans the tags over multiple lines, or your tags will include other tags, or ... .
- Much better is it to use a module like XML::Parser which will parse your xml-file and allow you to extract whatever you want from the xml-file
- Or you could go the XSLT-way and transform your xml-file into another xml-file. Excellent XSLT-modules exist, such as Xml::Sablotron or XML-LibXSLT or use XML::XSLT::Wrapper which provides a consistent interface to various XSLT-engines.
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law