Reply to Re: Remove data outside a pair of xml tags.

Your name:

Reply:


Posted by Tommy Gildseth on 06/21/06 20:01

Tommy Gildseth wrote:
> lazypig06@gmail.com wrote:
>
>>
>> --------------------------------------------------------------
>> Junk dataflasjfasj
>> <firsttag>
>> <secondtag>data</secondtag>
>> <thirdtag>whatever</thirdtag>
>> </firsttag>
>>
>> junk dataga.
>> ---------------------------------------------------------------
>>
>> Does someone know how to remove the junk in the file and just return
>> the actual xml stuff( including the <firsttag> tag ?
>
>
> I believe this should work:
>
> ....snip snip php code

Well.... not quite, if the junk data contains < or >

This might be better:

<?php
$str = 'Junk> dat<aflasjfasj
<firsttag>
<secondtag>data</secondtag>
<thirdtag>whatever</thirdtag>
</firsttag>

junk data>ga. < sadfsda fsd
';

echo preg_replace('/.*?(<[^<]+>.*<.*?>).*/s', '$1', $str);
?>

--
Tommy Gildseth
http://design.twobarks.com/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация