SimpleXML Set Attributes


/ Published in: PHP
Save to your folder(s)

Convenience function to set a SimpleXMLElement's attributes quickly.


Copy this code and paste it in your HTML
  1. function set_simplexml_attributes($element, $attributes) {
  2. foreach($attributes as $key => $value) {
  3. $element->addAttribute($key, $value);
  4. }
  5. }
  6.  
  7. // ex:
  8. set_simplexml_attributes($categoryElement, array(
  9. "id" => "1",
  10. "enabled" => "true",
  11. "iconUrl" => $this->thinger,
  12. "tooltip" => "popups/study.swf"
  13. ));

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.