help with getAttribute()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lehula
Forum Newbie
Posts: 7
Joined: Sat Jul 14, 2007 4:33 pm

help with getAttribute()

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
Post Reply