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/
Navigation:
[Reply to this message]
|