News Feed
Jobs Feed
Sections




News Archive
feed this:

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

PHPBuilder.com:
PHP Simple HTML DOM Parser Editing HTML Elements in PHP
September 08, 2011 @ 10:06:07

On PHPBuilder.com today there's a new tutorial from Vojislav Janjic about using a simple DOM parser in PHP to edit the markup even if it's not correctly W3C-formatted - the Simple HTML DOM Parser

Simple HTML DOM parser is a PHP 5+ class which helps you manipulate HTML elements. The class is not limited to valid HTML; it can also work with HTML code that did not pass W3C validation. Document objects can be found using selectors, similar to those in jQuery. You can find elements by ids, classes, tags, and much more. DOM elements can also be added, deleted or altered.

They help you get started using the parser, passing in the HTML content to be handled (either directly via a string or loading a file) and locating elements in the document either by ID, class or tag. Selectors similar to those in CSS are available. Finally, they show how to find an object and update its contents, either by adding more HTML inside or by appending a new object after it.

0 comments voice your opinion now!
simple html dom parse tutorial selector find replace edit


Fabien Potencier's Blog:
Parsing XML documents with CSS selectors
April 02, 2010 @ 09:41:27

In a new post Fabien Potencier talks about how he took the Python lxml.cssselect component from Python, ported it over to PHP and made a library that allows you to parse XML with the handy CSS selectors rather than using XPath.

Odds are you [also] need to parse some from time to time: because you consume a web service and want to extract some information, or because you want to gather data from scraped web pages, or just because you want to write functional tests for a website.

The CssSelector tool allows you to convert a CSS selector into an XPath that can, in turn, be pushed into the XPath function of the PHP DOM XML functionality. He gives a few examples of using it for a simple "find" and for something more complex involving a SimpleXML object too.

The library can be downloaded from github here.

0 comments voice your opinion now!
xml parse css selector cssselector tutorial



Community Events











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


language opinion unittest composer release overview facebook security podcast hack code symfony2 application introduction component framework hhvm package support install

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