On Tue, Feb 2, 2010 at 2:29 PM, Ryan S <genphp@xxxxxxxxx> wrote: > Hey! > i'm just starting with PHP's DOM-XML and need a little help please. > > > Basically, first i am trying to see if a input like a textbox has a 'VALUE=' associated with it, if yes, i leave it be, if no, i add a default value. > > This *is working* as can be seen by the attached code below. > > But a bit confused as to how to do the same for a textarea as textarea's do not have a 'VALUE=' attribute. > > Heres my code: > > > $website_data = file_get_contents('dom_test.html');//load the website data, > > $dom = new DomDocument; //make a new DOM container in PHP > $dom->loadHTML($website_data); //load all the fetched data into the DOM container > [snip] > // ***** now we come to the textarea bit that is not working ***** > > $inputs2 = $dom->getElementsByTagName('textarea'); // Find textareas > > foreach ($inputs2 as $input2) { > if(!$input2->firstChild.nodeValue=="") { > $input2->firstChild.nodeValue=="it works!"; > } > } > > > > echo $dom->saveHTML(); > ?> > > +++++++++++++++++++++++++++++++ > > // I have even tried this instead of the above: > > foreach ($inputs2 as $input2) { > if(!$input2->getAttribute("defaultValue")=="") { > $input2->setAttribute("defaultValue","it works!"); > } > } > > but no joy. > > I'm betting its pretty simple but i dont have a "DOM chart" for php, the only ones i have been able to find via google are for javascript like this one: http://www.hscripts.com/tutorials/javascript/dom/textarea-events.php > > > and that chart does not help much. Does anyone have a PHP DOM chart or a resource that i can use to get started using this? > > Thanks in advance! > Ryan > I think what you are looking for is $input2->textContent in PHP. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php