/**
  * Tries to parse the error response xml from the AdWords API server as an
  * object. This method is used in parsing all error responses when API
  * version >= v201209, and in other versions when apiMode header is mentioned
  * in the request headers.
  *
  * @param String $responseXml the error response xml
  *
  * @return Object the parsed error object, or null if the response cannot
  * be parsed.
  */
 private static function ParseApiErrorXml($responseXml)
 {
     $retval = null;
     try {
         $doc = XmlUtils::GetDomFromXml($responseXml);
         $retval = XmlUtils::ConvertDocumentToObject($doc);
         if (!is_array($retval->ApiError)) {
             $retval->ApiError = array($retval->ApiError);
         }
     } catch (\Exception $e) {
         // There was a parse exception and hence this response cannot be
         // interpreted as an xml.
     }
     return $retval;
 }
 /**
  * A typemap conversion function for parsing long values in SOAP responses.
  *
  * @param string $xml the XML snippet containing the long value.
  *
  * @return mixed the inner long value as an integer, float, or string
  */
 public static function TypemapLongFromXml($xml)
 {
     $document = XmlUtils::GetDomFromXml($xml);
     $tag = $document->documentElement->localName;
     $value = $document->documentElement->nodeValue;
     $isIdField = preg_match('/^id$|Id$|ID$/', $tag);
     if (!$isIdField) {
         if (strcmp(strval(intval($value)), $value) === 0) {
             return intval($value);
         } elseif (strcmp(sprintf('%.0f', floatval($value)), $value) === 0) {
             return floatval($value);
         }
     }
     return $value;
 }