<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Developer Tutorials' Webmaster Blog &#187; 2008 &#187; August</title>
	<atom:link href="http://www.developertutorials.com/blog/date/2008/08/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.developertutorials.com/blog</link>
	<description>Keeping webmasters up-to-date on technology.</description>
	<lastBuildDate>Thu, 18 Feb 2010 19:01:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Styling Disabled Buttons / Disabled Text Boxes in CSS</title>
		<link>http://www.developertutorials.com/blog/web/styling-disabled-buttons-disabled-text-boxes-in-css-404/</link>
		<comments>http://www.developertutorials.com/blog/web/styling-disabled-buttons-disabled-text-boxes-in-css-404/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 11:08:23 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
				<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/web/styling-disabled-buttons-disabled-text-boxes-in-css-404/</guid>
		<description><![CDATA[As your forms grow in complexity, you&#8217;ll probably find a need to temporarily disable an input &#8211; either a button, a text box, or some other element. This is quite easy in HTML &#8211; the disabled attribute comes to the rescue. But just how do you style those fields, and convey that they are temporarily [...]]]></description>
			<content:encoded><![CDATA[<p>As your forms grow in complexity, you&#8217;ll probably find a need to temporarily disable an input &#8211; either a button, a text box, or some other element. This is quite easy in HTML &#8211; the disabled attribute comes to the rescue. But just how do you style those fields, and convey that they are temporarily disabled?</p>
<p><span id="more-404"></span></p>
<p>Let&#8217;s consider this standard input field:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; value=&quot;Text.&quot; disabled /&gt;</pre></div></div>

<input type="text" value="Text." disabled />
<p>Pretty standard stuff. Your web browser will automatically style it a little, but mostly just prevent the user from editing without any real visual hints. But let&#8217;s add some basic CSS to convey the state of the input, and to standardise it across our site and on most platforms. If we add the following CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">input<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ddd</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<input type="text" value="Text." disabled style="border:1px solid #999;background-color:#ddd" />
<p>But wait &#8211; our demo uses inline styles, but your browser might not have just styled that properly if we used a full CSS declaration. We don&#8217;t set a value for the disabled attribute &#8211; it&#8217;s a <em>minimized</em> attribute. To get IE to play nicely with it (and for XHTML), we&#8217;ll have to set the value to &#8220;disabled&#8221;:</p>
<p> <em style="display:none"><a href="http://planet2025.net?the_wrestler">watch the wrestler in HD</a></em></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; value=&quot;Text.&quot; disabled=&quot;disabled&quot; /&gt;</pre></div></div>

<p>If possible, just for total compatibility, we can also add a &#8220;disabled&#8221; class that IE6 will respect and apply styles for correctly.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; value=&quot;Text.&quot; disabled=&quot;disabled&quot; class=&quot;disabled&quot; /&gt;</pre></div></div>

<p>We can then change the CSS selector we&#8217;re using:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">input<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;disabled&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">,</span> input.disabled</pre></div></div>

<p>And we&#8217;re done! This works across every major browser &#8211; IE6+ and FF1.0+ tested, and Safari 3 / Opera 9.5 should be fine as well. The Sitepoint CSS reference has further information on compatibility, <a href="http://reference.sitepoint.com/css/attributeselector#compatibilitysection" target="_blank">available here</a>.</p>
<p>Finally, if you want to see how Firefox styles disabled fields by default, load up your resource://gre/res/forms.css file (you&#8217;ll have to copy and paste it to your address bar). There are a number of lengthy selectors with just a few rules, but here&#8217;s the big one, way down the bottom:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">button<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:active</span><span style="color: #00AA00;">,</span> button<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;reset&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:active</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;reset&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:active</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">,</span>
select<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&gt;</span> input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">,</span>
select<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&gt;</span> input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:active</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:active</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">6px</span> <span style="color: #933;">0px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">outset</span> ButtonFace<span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> GrayText<span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inherit</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>GrayText is actually a system color &#8211; it&#8217;s defined by the CSS 2.1 specification and supported on and off in various browsers. These &#8220;special&#8221; color keywords are supposed to match the local system styles &#8211; on a Windows machine, for instance, Firefox would use the color: GrayText rule to style text in disabled fields with the same color that the local Windows system uses. A list of options is available on the <a href="http://reference.sitepoint.com/css/colorvalues">CSS reference</a> as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/web/styling-disabled-buttons-disabled-text-boxes-in-css-404/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Easy Screen Scraping in PHP with the Simple HTML DOM Library</title>
		<link>http://www.developertutorials.com/blog/php/easy-screen-scraping-in-php-simple-html-dom-library-simplehtmldom-398/</link>
		<comments>http://www.developertutorials.com/blog/php/easy-screen-scraping-in-php-simple-html-dom-library-simplehtmldom-398/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 07:10:54 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/easy-screen-scraping-in-php-simple-html-dom-library-simplehtmldom-398/</guid>
		<description><![CDATA[Client-side developers always had it easy &#8211; libraries such as jQuery and Prototype make finding elements on the page reliable and efficient. In PHP, regular expressions tend to get rather messy, DOM calls can be confusing and verbose, and often the string functions just aren&#8217;t enough. In this tutorial, I&#8217;ll show you how to use [...]]]></description>
			<content:encoded><![CDATA[<p>Client-side developers always had it easy &#8211; libraries such as jQuery and Prototype make finding elements on the page reliable and efficient. In PHP, regular expressions tend to get rather messy, DOM calls can be confusing and verbose, and often the string functions just aren&#8217;t enough. In this tutorial, I&#8217;ll show you how to use the middle ground &#8211; the open source PHP Simple HTML DOM Parser library, which provides jQuery-grade awesomeness for easy screen scraping without messy regular expressions.<span id="more-398"></span></p>
<p>The <a href="http://simplehtmldom.sourceforge.net/">Simple HTML DOM Parser</a> is implemented as a simple PHP class and a few helper functions. It supports CSS selector style screen scraping (such as in jQuery), can handle invalid HTML, and even provides a familiar interface to manipulate a DOM.</p>
<p>Here&#8217;s a sample of simplehtmldom in action:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> file_get_dom<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.google.com/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$element</span><span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">href</span><span style="color: #339933;">;</span></pre></div></div>

<p>This snippet is fairly self explanatory &#8211; <code>file_get_dom()</code> is a simple helper function in the library that fetches the page and constructs a new simplehtmldom object around it. Once the object is available, we can easily use simple CSS selectors to find our elements &#8211; in this case, anchors &#8211; and iterate over them just as we would with PHP 5&#8217;s standard DOM classes. (The equivalent code with the standard DOM classes is twice as long.)</p>
<p>But the library doesn&#8217;t stop there &#8211; as well as traversing the DOM and extracting information, you can also alter it. Consider this snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> str_get_html<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'
&lt;div id=&quot;hello&quot;&gt;Hello&lt;/div&gt;
&lt;div id=&quot;world&quot;&gt;World&lt;/div&gt;
&nbsp;
'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'div'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">class</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'bar'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'div[id=hello]'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">innertext</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'foo'</span><span style="color: #339933;">;</span></pre></div></div>

<p>The library supports many DOM-style approaches for manipulation, from exposing real attributes as shown here, to a few helper methods. It also includes other methods to traverse the current node &#8211; <code>children()</code>, <code>parent()</code>, <code>first_child()</code> and so on.</p>
<p>Real scraping? Easy. Here&#8217;s their Slashdot sample:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> file_get_html<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://slashdot.org/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'div.article'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$article</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span>     <span style="color: #339933;">=</span> <span style="color: #000088;">$article</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'div.title'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">plaintext</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'intro'</span><span style="color: #009900;">&#93;</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$article</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'div.intro'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">plaintext</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'details'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$article</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'div.details'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">plaintext</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$articles</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$articles</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And finally, there&#8217;s always a simple save mechanism:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'altered-dom.html'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ready to get started? Head over to the <a href="http://simplehtmldom.sourceforge.net/">project website</a>, <a href="http://simplehtmldom.sourceforge.net/manual.htm">online documentation</a> or the <a href="https://sourceforge.net/projects/simplehtmldom/">project page on SourceForge</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/easy-screen-scraping-in-php-simple-html-dom-library-simplehtmldom-398/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>
