Roman Neuhauser wrote:
> # [EMAIL PROTECTED] / 2007-01-25 09:27:59 +1100:
>> I must be dumb as I have been battling my way through regular expression
>> examples for a while and I can not work out why the following does not work
>> properly. I am the first to admit that regular expressions confuse me 
>> greatly.
>>
>> The string is a piece of XML as follows and I have put that string into a
>> variable called $xml_string
>>
>>
>> <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.

<accent voice="pirate">
        you be needing an ungreedy modifier on yer regex.
</accent>

see here:
http://php.net/manual/en/reference.pcre.pattern.modifiers.php

> Are you doing this to learn regular expressions or are you actually
> trying to do work? Because you're going the wrong way.
> It's XML, why do you treat it as text?

not everyone shares that sentiment. in terms of lowest common denominator
XML is also a string. then there is the question of whether it's actually
marked as XML, whether there is valid DTD and whether the XML itself validates
against the DTD - if any of the answers is 'no' then your looking at tag soup.

there is a lot more tagsoup in this world than there is proper xml.

that said it can't hurt to throw simpleXML at the problem :-)

> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to