# [EMAIL PROTECTED] / 2007-01-25 09:27:59 +1100:
> <flights>
> <flight flightId="19417361" addAdtPrice="0.0" addChdPrice="0.0"
> addInfPrice="0.0">
> <legXRefs>
> <legXRef legId="23862812" class="V"></legXRef>
> <legXRef legId="23862813" class="V"></legXRef>
> </legXRefs>
> </flight>
> <flight flightId="19417360" addAdtPrice="0.0" addChdPrice="0.0"
> addInfPrice="0.0">
> <legXRefs>
> <legXRef legId="23862810" class="V"></legXRef>
> <legXRef legId="23862811" class="V"></legXRef>
> </legXRefs>
> </flight>
> </flights>
>
>
> What I am trying to do is extract the first <flight ..... /flight> chunk.
> preg_match('#<flight .*\/flight>#', $xml_string,$matches);
> $tempstr = $matches[0];
>
> What I actually get in $tempstr is everything from the first <flight through
> to
> the last (second) </flight>
Strange, you should have gotten nothing:
s (PCRE_DOTALL)
If this modifier is set, a dot metacharacter in the pattern matches
all characters, including newlines. Without it, newlines are
excluded.
> I would have expected preg_match to have matched from the first <flight
> through
> to the first </flight>.
As Jochem wrote, you also need U (PCRE_UNGREEDY).
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php