Want more features on Pastebin? Sign Up, it's FREE!
Guest

Example DOM parsing XML

By: a guest on Feb 6th, 2012  |  syntax: PHP  |  size: 0.32 KB  |  views: 60  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $dom = new DOMDocument('1.0', 'UTF-8');
  2. $dom->loadXML($xml_post);
  3. $msgids = $dom->getElementsByTagName('custom-attribute');
  4. foreach($msgids as $k=>$v){
  5.     $tmp_msg = array();
  6.     $tmp_msg['attr_value'] = $v->getAttribute('attribute-id');
  7.     $tmp_msg['tag_value'] = $v->item(0)->nodeValue;
  8.     $msgid[] = $tmp_msg;
  9. }
clone this paste RAW Paste Data