src/phpGPX/phpGPX.php
public static function parse($xml)
	{
		$xml = simplexml_load_string($xml);

		$gpx = new GpxFile();

		// Parse creator
		$gpx->creator = isset($xml['creator']) ? (string)$xml['creator'] : null;

		// Parse metadata
		$gpx->metadata = isset($xml->metadata) ? MetadataParser::parse($xml->metadata) : null;

		// Parse waypoints
		$gpx->waypoints = isset($xml->wpt) ? WaypointParser::parse($xml->wpt) : [];

		// Parse tracks
		$gpx->tracks = isset($xml->trk) ? TrackParser::parse($xml->trk) : [];

		// Parse routes
		$gpx->routes = isset($xml->rte) ? RouteParser::parse($xml->rte) : [];

		return $gpx;
	}
public static function parse($xml)
	{
		$xml = simplexml_load_string($xml);

		$gpx = new GpxFile();

		// Parse creator
		$gpx->creator = isset($xml['creator']) ? (string)$xml['creator'] : null;

		// Parse metadata
		$gpx->metadata = isset($xml->metadata) ? MetadataParser::parse($xml->metadata) : null;

		// Parse waypoints
		$gpx->waypoints = isset($xml->wpt) ? WaypointParser::parse($xml->wpt) : [];

		// Parse tracks
		$gpx->tracks = isset($xml->trk) ? TrackParser::parse($xml->trk) : [];

		// Parse routes
		$gpx->routes = isset($xml->rte) ? RouteParser::parse($xml->rte) : [];

		return $gpx;
	}
public static function parse ( $ xml ) { $ xml = simplexml_load_string ( $ xml ) ; $ gpx = new GpxFile ( ) ; // Parse creator $ gpx -> creator = isset ( $ xml [ 'creator' ] ) ? ( string ) $ xml [ 'creator' ] : null ; // Parse metadata $ gpx -> metadata = isset ( $ xml -> metadata ) ? MetadataParser :: parse ( $ xml -> metadata ) : null ; // Parse waypoints $ gpx -> waypoints = isset ( $ xml -> wpt ) ? WaypointParser :: parse ( $ xml -> wpt ) : [ ] ; // Parse tracks $ gpx -> tracks = isset ( $ xml -> trk ) ? TrackParser :: parse ( $ xml -> trk ) : [ ] ; // Parse routes $ gpx -> routes = isset ( $ xml -> rte ) ? RouteParser :: parse ( $ xml -> rte ) : [ ] ; return $ gpx ; }
Parse GPX data string.
@param $xml
@return GpxFile
Parse GPX data string .