Skip to content

Instantly share code, notes, and snippets.

@netojoaobatista
Created September 16, 2013 13:26
Show Gist options
  • Save netojoaobatista/6580654 to your computer and use it in GitHub Desktop.
Save netojoaobatista/6580654 to your computer and use it in GitHub Desktop.
<?php
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->load('xml.xml');
$xpath = new DOMXPath($dom);
$courses = array();
foreach( $xpath->query('.//course/area[text()="Educação e Pedagogia"]/..') as $node) {
$values = array();
foreach ($node->childNodes as $child) {
$values[$child->nodeName] = $child->nodeValue;
}
$courses[] = $values;
}
var_dump($courses);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment