public static PhoneMetadata.Builder LoadTerritoryTagMetadata(string regionCode, XElement element,
                                                                     string nationalPrefix)
        {
            var metadata = new PhoneMetadata.Builder();

            metadata.SetId(regionCode);
            if (element.HasAttribute(COUNTRY_CODE))
            {
                metadata.SetCountryCode(int.Parse(element.GetAttribute(COUNTRY_CODE)));
            }
            if (element.HasAttribute(LEADING_DIGITS))
            {
                metadata.SetLeadingDigits(ValidateRE(element.GetAttribute(LEADING_DIGITS)));
            }
            if (element.HasAttribute(INTERNATIONAL_PREFIX))
            {
                metadata.SetInternationalPrefix(ValidateRE(element.GetAttribute(INTERNATIONAL_PREFIX)));
            }
            if (element.HasAttribute(PREFERRED_INTERNATIONAL_PREFIX))
            {
                metadata.SetPreferredInternationalPrefix(
                    element.GetAttribute(PREFERRED_INTERNATIONAL_PREFIX));
            }
            if (element.HasAttribute(NATIONAL_PREFIX_FOR_PARSING))
            {
                metadata.SetNationalPrefixForParsing(
                    ValidateRE(element.GetAttribute(NATIONAL_PREFIX_FOR_PARSING), true));
                if (element.HasAttribute(NATIONAL_PREFIX_TRANSFORM_RULE))
                {
                    metadata.SetNationalPrefixTransformRule(
                        ValidateRE(element.GetAttribute(NATIONAL_PREFIX_TRANSFORM_RULE)));
                }
            }
            if (!string.IsNullOrEmpty(nationalPrefix))
            {
                metadata.SetNationalPrefix(nationalPrefix);
                if (!metadata.HasNationalPrefixForParsing)
                {
                    metadata.SetNationalPrefixForParsing(nationalPrefix);
                }
            }
            if (element.HasAttribute(PREFERRED_EXTN_PREFIX))
            {
                metadata.SetPreferredExtnPrefix(element.GetAttribute(PREFERRED_EXTN_PREFIX));
            }
            if (element.HasAttribute(MAIN_COUNTRY_FOR_CODE))
            {
                metadata.SetMainCountryForCode(true);
            }
            if (element.HasAttribute(MOBILE_NUMBER_PORTABLE_REGION))
            {
                metadata.SetMobileNumberPortableRegion(true);
            }
            return(metadata);
        }
        public static PhoneMetadata.Builder LoadTerritoryTagMetadata(String regionCode, XmlElement element,
                                                                     String nationalPrefix)
        {
            var metadata = new PhoneMetadata.Builder();

            metadata.SetId(regionCode);
            metadata.SetCountryCode(int.Parse(element.GetAttribute(COUNTRY_CODE)));
            if (element.HasAttribute(LEADING_DIGITS))
            {
                metadata.SetLeadingDigits(ValidateRE(element.GetAttribute(LEADING_DIGITS)));
            }
            metadata.SetInternationalPrefix(ValidateRE(element.GetAttribute(INTERNATIONAL_PREFIX)));
            if (element.HasAttribute(PREFERRED_INTERNATIONAL_PREFIX))
            {
                String preferredInternationalPrefix = element.GetAttribute(PREFERRED_INTERNATIONAL_PREFIX);
                metadata.SetPreferredInternationalPrefix(preferredInternationalPrefix);
            }
            if (element.HasAttribute(NATIONAL_PREFIX_FOR_PARSING))
            {
                metadata.SetNationalPrefixForParsing(
                    ValidateRE(element.GetAttribute(NATIONAL_PREFIX_FOR_PARSING), true));
                if (element.HasAttribute(NATIONAL_PREFIX_TRANSFORM_RULE))
                {
                    metadata.SetNationalPrefixTransformRule(
                        ValidateRE(element.GetAttribute(NATIONAL_PREFIX_TRANSFORM_RULE)));
                }
            }
            if (!String.IsNullOrEmpty(nationalPrefix))
            {
                metadata.SetNationalPrefix(nationalPrefix);
                if (!metadata.HasNationalPrefixForParsing)
                {
                    metadata.SetNationalPrefixForParsing(nationalPrefix);
                }
            }
            if (element.HasAttribute(PREFERRED_EXTN_PREFIX))
            {
                metadata.SetPreferredExtnPrefix(element.GetAttribute(PREFERRED_EXTN_PREFIX));
            }
            if (element.HasAttribute(MAIN_COUNTRY_FOR_CODE))
            {
                metadata.SetMainCountryForCode(true);
            }
            if (element.HasAttribute(LEADING_ZERO_POSSIBLE))
            {
                metadata.SetLeadingZeroPossible(true);
            }
            return(metadata);
        }