Page 1 of 1

help with getAttribute()

Posted: Thu Jul 19, 2007 9:21 am
by lehula
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I've been searching the web for a good example on how to use getAttribute() for php, but I can't find one. I found one, but it was talking about loading a file and nodes and a class...... Can I just use getAttribute to easily get the colors and height and width of this div. Or is there another way to put them in an array. Any help at all would be appreciated. Thanks.

[syntax="html"]<div id="test" style="position:absolute; background-image:url("http://");
left:484; top:568; overflow:auto;background-color:; color: FFFFFF;
height:400; width:300;font-size:16pt; text-align: center;
font-family:Monotype Corsiva;border-color:000000;
border-width:6px; border-style: solid;z-index:2px;
background-repeat:repeat; background-position:top left;
opacity:1; filter: alpha(opacity=100)"></div>

feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Jul 19, 2007 2:40 pm
by volka
php itself isn't aware of the html it might send to the client.
echo '<html><head>.....</html>'; or echo 'Mary had a little lamb'; or readfile($pdffiel); makes no difference for server-side php.
The client-side browser on the other hand parses a html document and creates a dom model accordingly. You can access this model via javascript.
--
php itself isn't html aware but there is an xml enxtension for php5 that can load and parse xml/html documents.
e.g.

Code: Select all

<?php
$dom = new DOMDocument;
@$dom->loadHTMLFile('http://php.net')
	or die('could not load document from http://php.net');
$xpath = new DOMXPath($dom);
$ns=$xpath->query('//div[@id]');
foreach( $ns as $node ) {
  echo 'id: ', $node->getAttribute('id'), "<br />\n";
}
see also: http://php.net/xml