<?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/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>php5 &#8211; MaxVergelli.com</title>
	<atom:link href="https://www.maxvergelli.com/tag/php5/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.maxvergelli.com</link>
	<description>sourcecode repository</description>
	<lastBuildDate>Sat, 11 Apr 2020 17:10:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i2.wp.com/www.maxvergelli.com/wp-content/uploads/2020/04/wp-1586823685141.png?fit=32%2C32&#038;ssl=1</url>
	<title>php5 &#8211; MaxVergelli.com</title>
	<link>https://www.maxvergelli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">34603511</site>	<item>
		<title>How to parse and process HTML/XML in PHP</title>
		<link>https://www.maxvergelli.com/how-to-parse-and-process-html-xml-in-php/</link>
					<comments>https://www.maxvergelli.com/how-to-parse-and-process-html-xml-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Wed, 15 Apr 2020 16:44:00 +0000</pubDate>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[String Manipulation Algorithms]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[find-html]]></category>
		<category><![CDATA[grabbing]]></category>
		<category><![CDATA[html-manipulation]]></category>
		<category><![CDATA[html-parser]]></category>
		<category><![CDATA[libxml]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[parsing-html]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php-class]]></category>
		<category><![CDATA[php-extension]]></category>
		<category><![CDATA[php-query]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[php7]]></category>
		<category><![CDATA[query-path]]></category>
		<category><![CDATA[simple-html-dom]]></category>
		<category><![CDATA[simple-xml]]></category>
		<category><![CDATA[xml-parser]]></category>
		<category><![CDATA[xml-reader]]></category>
		<guid isPermaLink="false">https://www.maxvergelli.com/?p=239</guid>

					<description><![CDATA[Simple HTML DOM is a great open-source parser: simplehtmldom.sourceforge It treats DOM elements in an object-oriented way, and the new iteration has a lot of coverage for non-compliant code. There are also some great functions like you&#8217;d see in JavaScript, &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-parse-and-process-html-xml-in-php/" aria-label="How to parse and process HTML/XML in PHP">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>Simple HTML DOM is a great open-source parser:</p>



<p><a href="http://simplehtmldom.sourceforge.net/">simplehtmldom.sourceforge</a></p>



<p>It treats DOM elements in an object-oriented way, and the new iteration has a lot of coverage for non-compliant code. There are also some great functions like you&#8217;d see in JavaScript, such as the &#8220;find&#8221; function, which will return all instances of elements of that tag name.</p>



<p>I&#8217;ve used this in a number of tools, testing it on many different types of web pages, and I think it works great.</p>



<p>These are the main features:</p>



<ul><li>HTML DOM parser written in PHP 5+ that lets you manipulate HTML in a very easy way</li><li>Require PHP 5+</li><li>Supports invalid HTML</li><li>Find tags on an HTML page with selectors just like jQuery</li><li>Extract contents from HTML in a single line</li></ul>



<p><strong>How to get HTML elements:</strong></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">// Create DOM from URL or file
$html = file_get_html('http://www.example.com/');

// Find all images
foreach($html-&gt;find('img') as $element)
       echo $element-&gt;src . '&lt;br&gt;';

// Find all links
foreach($html-&gt;find('a') as $element)
       echo $element-&gt;href . '&lt;br&gt;';</pre></div>



<p><strong>How to modify HTML elements:</strong></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">// Create DOM from string
$html = str_get_html('&lt;div id=&quot;hello&quot;&gt;Hello&lt;/div&gt;&lt;div id=&quot;world&quot;&gt;World&lt;/div&gt;');

$html-&gt;find('div', 1)-&gt;class = 'bar';

$html-&gt;find('div[id=hello]', 0)-&gt;innertext = 'foo';

echo $html;</pre></div>



<p><strong>Extract content from HTML:</strong></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">// Dump contents (without tags) from HTML
echo file_get_html('http://www.google.com/')-&gt;plaintext;</pre></div>



<p><strong>Scraping Slashdot:</strong></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">// Create DOM from URL
$html = file_get_html('http://slashdot.org/');

// Find all article blocks
foreach($html-&gt;find('div.article') as $article) {
    $item['title']     = $article-&gt;find('div.title', 0)-&gt;plaintext;
    $item['intro']    = $article-&gt;find('div.intro', 0)-&gt;plaintext;
    $item['details'] = $article-&gt;find('div.details', 0)-&gt;plaintext;
    $articles[] = $item;
}

print_r($articles);</pre></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-parse-and-process-html-xml-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">239</post-id>	</item>
	</channel>
</rss>
