Hi,
how can I select an element of my html document using php ?
getElementById('id');
thanks
element selector ?
Moderator: General Moderators
Re: element selector ?
var abc=document.getElementById('idOfSpecificHtmlElement').value;
YOu write this code u will get value in abc variable of javascript.
YOu write this code u will get value in abc variable of javascript.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: element selector ?
Using PHP you can't just get a HTML element, the HTML is usually produced by PHP, so you should have access to whatever you want already. On the other hand, you could do file_get_contents() on a HTML file and then parse it with an XML parser or similar, and work from there.
Re: element selector ?
uhm ok... than I can only use client-side technologies to edit existent html ?
My problem is that I want to automatically change the html code inserted by my customer in content management system editor
My problem is that I want to automatically change the html code inserted by my customer in content management system editor
Re: element selector ?
You can use DOMDocument if it's compiled into your version of PHP, or SimpleHTMLDOM if it's not (http://sourceforge.net/projects/simplehtmldom/).
Re: element selector ?
If I use DOMDocument, should I load the html like this ?
or is any other easier way to do it ?
thanks
Code: Select all
$xmlDoc = new DOMDocument();
$xmlDoc->load( 'myPage.html' );thanks
Last edited by Benjamin on Tue Jun 23, 2009 10:18 am, edited 1 time in total.
Reason: Changed code type from text to php.
Reason: Changed code type from text to php.