/** * Parse all of the xml attributes from a SimpleXml node * and set them to the given object * * @param SimpleXmlElement $xml * @param ClassMetadata $metadata * @param stdClass $obj */ protected function parseAttributes(\SimpleXmlElement $xml, ClassMetadata $metadata, $obj) { foreach ($metadata->getAttributes() as $name => $info) { $property = $info[0]; $nodeName = $info[1]; if (!is_null($nodeName)) { $node = $xml->{$nodeName}; $value = (string) $node[$name]; } else { $value = (string) $xml[$name]; } $setter = 'set' . ucfirst($property); $obj->{$setter}($value); } }