Skip to content

Instantly share code, notes, and snippets.

@quagliato
Created July 10, 2014 22:56
Show Gist options
  • Save quagliato/d066911c17d4cc3f4eed to your computer and use it in GitHub Desktop.
Save quagliato/d066911c17d4cc3f4eed to your computer and use it in GitHub Desktop.
Iterate XMLs
<?php
$xml = simplexml_load_file("file.xml");
$xmlName = $xml->getName();
foreach ($xml->children() as $child) {
foreach ($child->children() as $grandson) {
if ($grandson == "tag1") {
}
if ($grandson == "tag2") {
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment