Skip to content

Instantly share code, notes, and snippets.

@johnrobertwilson
Created February 15, 2012 19:05
Show Gist options
  • Save johnrobertwilson/1838197 to your computer and use it in GitHub Desktop.
Save johnrobertwilson/1838197 to your computer and use it in GitHub Desktop.
XML parsing
$file_path = drupal_get_path('module', 'cc_ingestion_engine') . '/xml/cbindicators_revised.xml';
include($file_path . '/cc_ingestion_engine.module');
$content = utf8_encode(file_get_contents($file_path));
$xml = simplexml_load_string($content);
$areas_xml_object = $xml->areas;
$charts_xml_object = $xml->charts;
$chart_types = $xml->chart_types;
$definition_sources_xml_object = $xml->definitionsources;
$indicators_xml_object = $xml->indicators;
$measures_xml_object = $xml->measures;
$populations_xml_object = $xml->populations;
// Convert areas xml to PHP array
$areas = json_encode($areas_xml_object);
$areas = json_decode($areas, TRUE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment