X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/f1c6a87aa137c11d0aff5a4b0e563ac2c2a8f82d..0e2a66e8de55b3719bd307261058b7f898598994:/app/models/node.rb diff --git a/app/models/node.rb b/app/models/node.rb index 4d48112fc..52c4b6d67 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -74,11 +74,13 @@ class Node < ApplicationRecord def self.from_xml(xml, create = false) p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR) doc = p.parse + pt = doc.find_first("//osm/node") - doc.find("//osm/node").each do |pt| - return Node.from_xml_node(pt, create) + if pt + Node.from_xml_node(pt, create) + else + raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/node element.") end - raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/node element.") rescue LibXML::XML::Error, ArgumentError => e raise OSM::APIBadXMLError.new("node", xml, e.message) end