deleting text enclosed by a tag with particular attribute values from html file
I have an html file which has both English and Arabic text. I need to delete all the Arabic texts from the file.
I observed that all the urdu texts come inside a <p>
or a <div>
tag with the attribute style="direction: rtl;"
which makes the Arabic text appear right to left.
stripped example:
<P style="direction:rtl">
<SPAN style="font-family:'serif'>Arabic Text: ������������</SPAN>
</P>
So I need to find all the tag blocks with the attribute style="direction:r开发者_如何学编程tl"
(I don't know much html, and I am not very sure it is called an attribute) and delete them. Tried Aptana Studio but I found it couldn't do the job either (please tell me if I missed a trick).
I tried to do it with Firebug, but couldn't figure it out (never used it before).
So can this be done with Firebug? Or, is there an HTML editor which'll let me search and list blocks with specific tags or attribute values?
Any help will be greatly appreciated.
There are all kinds of ways to do this; a Python program would be perhaps best if this was an ongoing operation.
But, since this is a Firebug question and stated to be a one-time operation, here's how to do it using Firebug and jQuery:
Make a backup copy of the original files.
Open the file in Firefox.
If using Noscript, or similar, make sure JavaScript is temporarily enabled for local files.
Open the Firebug console.
Reload the page if the console says it's needed.
Open the large command-line/command-box.
Paste in the following code:
var scriptNode = document.createElement ("script"); scriptNode.setAttribute ("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"); document.body.appendChild (scriptNode); function KilltheCrud () { jQuery('p[style*="rtl"]').remove (); jQuery('div[style*="rtl"]').remove (); } //-- Delay to allow jQuery to load and initialize. setTimeout (KilltheCrud, 444); //-- Adjust time delay if necessary
Press "Run".
The file should now be stripped, save the modified file.
Done! Repeat for the other files.
精彩评论