N
Num GG
Hi all,
Given two web pages from the same site (eg: a weblog site). These two
pages contain a certain number of <div> elements
One of this page is the "reference" page as the configuration of the
visibility of all the <div> elements is "memorized" in this page. The
visibility/invisibility of the divs is affected programmatically. This
page could be seen as a kind of mask:
// First page : reference page
<HTML>
<BODY>
<div id="header" class="header">bla bla: the header </div>
<div id="title" class="content" style="display: none;"> Bli bli bli,
the title </div>
<div id="main" class="content"> Blu blu blu, the content of the post</
div>
<div id="comments" class="comments" style="display: none;">Your
comments here:
<div class="content">one comment </div> // PLS: remark that these
<div> has no id
<div class="content">another comment </div>
<div class="content">a last comment </div>
</div>
<div class="advertissement" style="display: none"> bla bla bla ...
advertissement </div>
//and so on...
</BODY>
</HTML>
The second page could be any page of the same site. It may be either
the fresher version of the first one, either another page (eg: another
post of the blog). This page has obviously the same structure of the
"reference" page. But several new divs can be present in this version:
// Another page : the page we want to apply a mask of visible/
invisible divs from the "reference"
<HTML>
<BODY>
<div id="header" class="header">bla bla: the header </div>
<div id="title" class="content"> Bli bli bli, the title </div>
<div id="main" class="content"> Blu blu blu, the content of the post</
div>
<div id="comments" class="comments">Your comments here:
<div class="content">one comment </div>
<div class="content">another comment </div>
<div class="content">a last comment </div> //... that is not more
the last but it's not the problem...
<div class="content">yet another comment </div>
<div class="content">a comment </div>
<div class="content">a last comment </div>
</div>
<div class="advertissement"> bla bla bla ... advertissement </div>
<div class="on the same subject"> bla bla bla ... on the same subject
bla bla </div>
//and so on...
</BODY>
</HTML>
Now, the question is:
Is there a way to apply the reference page div's visibility options as
a mask to the second page?
In order to give this result (to end with this example):
// Another page : the page we want to apply a mask of visible/
invisible divs from the "reference"
<HTML>
<BODY>
<div id="header" class="header">bla bla: the header </div>
<div id="title" class="content" style="display: none;"> Bli bli bli,
the title </div>
<div id="main" class="content"> Blu blu blu, the content of the post</
div>
<div id="comments" class="comments" style="display: none;">Your
comments here:
<div class="content">one comment </div>
<div class="content">another comment </div>
<div class="content">a last comment </div> //... that is not more
the last but it's not the problem...
<div class="content">yet another comment </div>
<div class="content">a comment </div>
<div class="content">a last comment </div>
</div>
<div class="advertissement" style="display: none"> bla bla bla ...
advertissement </div>
<div class="on the same subject" style="display: none;"> bla bla
bla ... on the same subject bla bla</div>
// This last div must be set as invisible because it is not present in
the reference page.
//and so on...
</BODY>
</HTML>
I think I should use DOM Treewalker to filter the DOM tree but is it
the only way?
Cheers,
Num
Given two web pages from the same site (eg: a weblog site). These two
pages contain a certain number of <div> elements
One of this page is the "reference" page as the configuration of the
visibility of all the <div> elements is "memorized" in this page. The
visibility/invisibility of the divs is affected programmatically. This
page could be seen as a kind of mask:
// First page : reference page
<HTML>
<BODY>
<div id="header" class="header">bla bla: the header </div>
<div id="title" class="content" style="display: none;"> Bli bli bli,
the title </div>
<div id="main" class="content"> Blu blu blu, the content of the post</
div>
<div id="comments" class="comments" style="display: none;">Your
comments here:
<div class="content">one comment </div> // PLS: remark that these
<div> has no id
<div class="content">another comment </div>
<div class="content">a last comment </div>
</div>
<div class="advertissement" style="display: none"> bla bla bla ...
advertissement </div>
//and so on...
</BODY>
</HTML>
The second page could be any page of the same site. It may be either
the fresher version of the first one, either another page (eg: another
post of the blog). This page has obviously the same structure of the
"reference" page. But several new divs can be present in this version:
// Another page : the page we want to apply a mask of visible/
invisible divs from the "reference"
<HTML>
<BODY>
<div id="header" class="header">bla bla: the header </div>
<div id="title" class="content"> Bli bli bli, the title </div>
<div id="main" class="content"> Blu blu blu, the content of the post</
div>
<div id="comments" class="comments">Your comments here:
<div class="content">one comment </div>
<div class="content">another comment </div>
<div class="content">a last comment </div> //... that is not more
the last but it's not the problem...
<div class="content">yet another comment </div>
<div class="content">a comment </div>
<div class="content">a last comment </div>
</div>
<div class="advertissement"> bla bla bla ... advertissement </div>
<div class="on the same subject"> bla bla bla ... on the same subject
bla bla </div>
//and so on...
</BODY>
</HTML>
Now, the question is:
Is there a way to apply the reference page div's visibility options as
a mask to the second page?
In order to give this result (to end with this example):
// Another page : the page we want to apply a mask of visible/
invisible divs from the "reference"
<HTML>
<BODY>
<div id="header" class="header">bla bla: the header </div>
<div id="title" class="content" style="display: none;"> Bli bli bli,
the title </div>
<div id="main" class="content"> Blu blu blu, the content of the post</
div>
<div id="comments" class="comments" style="display: none;">Your
comments here:
<div class="content">one comment </div>
<div class="content">another comment </div>
<div class="content">a last comment </div> //... that is not more
the last but it's not the problem...
<div class="content">yet another comment </div>
<div class="content">a comment </div>
<div class="content">a last comment </div>
</div>
<div class="advertissement" style="display: none"> bla bla bla ...
advertissement </div>
<div class="on the same subject" style="display: none;"> bla bla
bla ... on the same subject bla bla</div>
// This last div must be set as invisible because it is not present in
the reference page.
//and so on...
</BODY>
</HTML>
I think I should use DOM Treewalker to filter the DOM tree but is it
the only way?
Cheers,
Num