I want to set id of an element. I'm using php dom. I could not understand how following will work.
DOMElement::setIdAttribute ( string $name , bool $isId )
The only description I found for this in manual is - Declares the attribute name to be of type ID.
How can I do this ?
What about
DOMElement::setAttribute
? You could justsetAttribute('id', 'your_id')
, or am I missing something? After that, you could usesetIdAttribute('id', TRUE)
to mark it as the ID.If you want to add an id attribute to your html element so that it looks like
<p id="frob">...
you dont usesetIdAttribute()
- it declares that the attribute$name
can be used as an unique identifier for that element - as an alternative/addition of theid
attribute. UsesetAttribute()
like so:use for example: