DOM

From: Date: Sat, 13 Jan 2001 00:30:03 +0000
Subject: DOM
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-4963@lists.php.net to get a copy of this message
Hi folks, I'm still new to HTML, Javascript and PHP but learning (fast hopefully). I've just started accessing DOM elements. I have worked out how to update the contents of table cells directly using this method, etc. In Javascript I would use code like: alert("Value is: " + tablejames.firstChild.childNodes[1].childNodes[4].firstChild.firstChild.node Name); alert("Value is: " + tablejames.firstChild.childNodes[1].childNodes[5].firstChild.firstChild.node Value); This Javascript shows the name and value of the child element. Now I want to use PHP to extract data (values) from HTML pages like I do with the above Javascript. Is this possible? Obviously with the Javascript the HTML page has already been rendered in the browser (i.e. all tree elements have been created). This makes extracting data a simple case of finding the "#text" elements and reading in the values. Can I do the same thing with PHP and an HTML file I've downloaded from the Internet? Obviously this file is sitting on my server and hasn't been rendered in a browser... The whole point of this exercise is so that I can extract values from an HTML table and populate them into a database. Maybe it's easier to process the HTML file line by line and strip the unwanted HTML tags? However, with this approach I've got to hardcode each webpage... If this is a silly question then sorry but you only learn if you ask ;) Thanks James

« previous php.windows (#4963) next »