I am working on a project that pulls data from JMS queue using PHP and Zend Framework. The HTTP client response is below. All I need is the XML string.
I came up with /(.*)</RequestDetails>/gs which tests ok on http://gskinner.com/RegExr/ but the preg_match call is returning an empty matches array.
I’m going to continue to hunt around for a pattern, but thought I would post here as well.
Thanks to all who read, etc…
Steve
UPDATE: I can’t get the code to paste correctly. Here’s a link to a pastbin: http://pastebin.com/rQxzcfSg
The following snippet:
Generates this output:
I’ve used
preg_match_allinstead of/gflag, and also used(.*?)reluctant matching, which is really what you want to get multiple matches.To see why it makes a difference, in the following text, there are two
A.*?Zmatches, but only oneA.*Z.That said, parsing XML using regex is ill-advised. Use a proper XML parser; it’ll make your life much easier.