I need to delete the offer element with city Moscow in the following XML:
<offer id="14305" available="true">
<param name="City">Moscow</param>
</offer>
<offer id="14306" available="true">
<param name="City">LA</param>
</offer>
How can I do it with PHP regular expressions?
I tried:
preg_replace('/<offer[^(>Moscow<).]+?<\/offer>/s', ''. $string);
but without success.
I read your advices. It is really great. But I have a new problem with greedy:
<offer id="14305" available="true">
<param name="Color">Red</param>
<engine>XYZ</engine>
<param name="City">Moscow</param>
</offer>
<offer id="14306" available="true">
<param name="Color">Red</param>
<param name="City">LA</param>
</offer>
<offer id="14306" available="true">
<weight>1000</weight>
<param name="Color">Red</param>
<param name="City">LA</param>
</offer>
My regexp is too greedy :(
<offer.*?>\s*?<param.*?>\s*?Moscow\s*?<\/param>\s*?<\/offer>