News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Thomas Weinert's Blog:
Highlight Words In HTML
May 10, 2010 @ 10:34:24

In the latest post to his blog Thomas Weinert takes a look at a simple challenge someone asked him about - highlighting a section of HTML based on a search string - and his solution.

The challenge is to wrap given words in text content with a span and add a class to the span depending on the word. Do not touch elements, attributes, comments or processing instructions. Do it case insensitive and do it the safe way.

He uses the FluentDOM tool to get the job done. It allows him to create an XPath expression to single out the item to be highlighted (in this case a single or series of words) and wrap them in a matching span tag with the correct styles attached.

0 comments voice your opinion now!
fluentdom tutorial highlight word


blog comments powered by Disqus

Similar Posts

ThinkPHP Blog: Creating press-ready PDF documents on the fly including individual barcodes

MaltBlue.com: Using ZFTool for Basic Project Management

Gonzalo Ayuso's Blog: Using Monkey Patching to store files in CouchDb using the standard filesystem

PHPMaster.com: Dependency Injection with Pimple

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 10)


Community Events





Don't see your event here?
Let us know!


install series language threedevsandamaybe symfony2 testing podcast code introduction community interview release framework opinion experience list refactor developer laravel unittest

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework