public static function replaceAttributes($xml, $tagName, callable $callback)
	{
		if (strpos($xml, '<' . $tagName) === false)
		{
			return $xml;
		}

		return preg_replace_callback(
			'((<' . preg_quote($tagName) . ')(?=[ />])[^>]*?(/?>))',
			function ($m) use ($callback)
			{
				return $m[1] . self::serializeAttributes($callback(self::parseAttributes($m[0]))) . $m[2];
			},
			$xml
		);
	}