How do you parse and process HTML/XML in PHP? How can one parse HTML/XML and extract information from it? This is a General Reference question for the php tag Answer: Native XML Extensions I prefer using one of the native XML extensions since they come bundled with PHP, are usually faster than all the 3rd party libs and give me all the control I need over the markup. DOM The DOM extension allows you to operate on XML documents through the DOM API with PHP
undefined
Determine a User's Timezone Is there any standard way for a Web Server to be able to determine a user's timezone within a web page? Perhaps from a HTTP header or part of the user-agent string? Answer: timezone.js: function ajaxpage() { var url = "timezone.php"; var visitortime = new Date(); var time = visitortime.getTimezoneOffset()/60; var page_request = false; if (window.XMLHttpRequest) { page_request = new XMLHttpRequest(); } else if (window.ActiveXObject) { try { page_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ page_request = new ActiveXObject("Microsoft.XMLHTTP");
undefined
How do you disable browser Autocomplete on web form field / input tag? How do you disable autocomplete in the major browsers for a specific input (or form field)? Answer: Firefox 30 ignores autocomplete="off" for passwords, opting to prompt the user instead whether the password should be stored on the client. Note the following commentary from May 5, 2014: The password manager always prompts if it wants to save a password. Passwords are not saved without permission from the user. We are the third browser to implement this change, after IE and
undefined
Options for HTML scraping? I'm thinking of trying Beautiful Soup, a Python package for HTML scraping. Are there any other HTML scraping packages I should be looking at? Python is not a requirement, I'm actually interested in hearing about other languages as well. The story so far: Python Beautiful Soup lxml HTQL Scrapy Mechanize Ruby Nokogiri Hpricot Mechanize scrAPI scRUBYt! wombat Watir .NET Html Agility Pack WatiN Perl WWW::Mechanize Web-Scraper Java Tag Soup HtmlUnit Web-Harvest jARVEST jsoup Jericho HTML Parser JavaScript request cheerio artoo
undefined
Convert HTML + CSS to PDF with PHP? I'm now banging my head against a brick wall with this one. I have an HTML (not XHTML) document that renders fine in Firefox 3 and IE 7. It uses fairly basic CSS to style it and renders fine in HTML. I'm now after a way of converting it to PDF. I have tried: DOMPDF: it had huge problems with tables. I factored out my large nested tables and it helped (before it was just