registerXPathNamespace('gml', 'http://www.opengis.net/gml'); $nodeArray = $simpleXml->xpath("//gml:posList"); if (count($nodeArray) > 0 ) { return "3"; } $nodeArray = $simpleXml->xpath("//gml:pos"); if (count($nodeArray) > 0 ) { return "3"; } return "2"; throw new Exception("GML version could not be determined from XML."); } /** * Creates a GML object from a GeoJSON (http://www.geojson.org) String * * @return Gml * @param $geoJson String */ public function createFromGeoJson ($geoJson) { $gml2Factory = new Gml_2_Factory(); return $gml2Factory->createFromGeoJson($geoJson); } /** * Creates a GML object by parsing its XML representation. * * The GML version is determined by parsing * the XML document up-front. * * @return Wfs * @param $xml String */ public function createFromXml ($xml, $wfsConf) { try { $version = $this->getVersionFromXml($xml); switch ($version) { case "2": $e = new mb_warning("Using GML2 Factory..."); $factory = new Gml_2_Factory(); break; case "3": $e = new mb_warning("Using GML3 Factory..."); $factory = new Gml_3_Factory(); break; default: throw new Exception("Unknown GML version " . $version . " in XML: \n\n" . $xml); break; } return $factory->createFromXml($xml, $wfsConf); } catch (Exception $e) { new mb_exception($e); return null; } } } ?>