Nested Tag Replacement...????
Posted: Sat Aug 05, 2006 10:02 am
feyd | Please use
So you can replace anything in a particluar DIV TAG.. (DIV=MYTAG)
Now here is my problem...
The tag I want to replace has several NESTED div tags inside it...
(Example)
So if I want to replace the "MYTAG" in that example with:::
It will replace all the text in red below::::
Leaving me with a messed up page... seeing as it leaves two instances of "</div>" that do not belong.....
Note: Things I Have Tried:::
I have tried replacing the div tags from the inside out..
Replacing the tags inside the main tag I want to replace first
First Replacing -- <div id="NESTEDTAG2">Content</div>
Second Replacing -- <div id="NESTEDTAG1">Content</div>
Third Replacing -- <div id="MYTAG">Content</div>
Doesn't work like that... The Nested Tags do not always have the same ID or CLASS....
I have tried:
But since the end tags are not on a single line it doesn't replace anything...
----------------------------
Any help would be appreciated
and if this is impossible... let me know... LOL
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
OK if you are a PHP Guru you may be able to help me out here...
I have to replace some text in a script and here is what I am trying to accomplish:::
This will replace anything in between START and END.. note the (.*?)Code: Select all
$FFETADQW = preg_replace('/START.*?END/smi', '', $FFETADQW);Code: Select all
$FFETADQW = preg_replace('/<div id="MYTAG".*?<\/div>/smi', '', $FFETADQW);The tag I want to replace has several NESTED div tags inside it...
(Example)
Code: Select all
<div id="MYTAG">
Main Content...
<div id="NESTEDTAG1">Content
<div id="NESTEDTAG2">Content
</div>
</div>
</div>Code: Select all
$FFETADQW = preg_replace('/<div id="MYTAG".*?<\/div>/smi', '', $FFETADQW);Code: Select all
<div id="MYTAG">
Main Content...
<div id="NESTEDTAG1">Content
<div id="NESTEDTAG2">Content
</div>
</div>
</div>Note: Things I Have Tried:::
I have tried replacing the div tags from the inside out..
Replacing the tags inside the main tag I want to replace first
First Replacing -- <div id="NESTEDTAG2">Content</div>
Second Replacing -- <div id="NESTEDTAG1">Content</div>
Third Replacing -- <div id="MYTAG">Content</div>
Doesn't work like that... The Nested Tags do not always have the same ID or CLASS....
I have tried:
Code: Select all
$FFETADQW = preg_replace('/<div id="MYTAG".*?<\/div><\/div><\/div>/smi', '', $FFETADQW);----------------------------
and if this is impossible... let me know... LOL
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]