문제

웹 호스팅이 오른쪽 DB로 전환 될 때까지 조회 데이터베이스 테이블 대신에 사용할 수있는 XML 파일을 찾으려고 노력합니다.

누구든지 자녀가 우편 번호, 주 및 도시를 가진 요소가있는 XML 파일을 저에게 추천 할 수 있습니까? 예 :

<zip code="98117">
    <state>WA</state>
    <city>Seattle</state>
</zip>

또는

<entry>
    <zip>98117</zip>
    <state>WA</state>
    <city>Seattle</city>
</entry>

이 데이터를 쿼리하기 위해 C#에서 LINQ를 사용하겠습니다.

도움이 되었습니까?

해결책

이것을 확인하십시오. 몇 가지 다른 무료를 제공합니다.

https://stackoverflow.com/questions/24471/zip-code-database

다른 팁

다음에는 무료 우편 번호 데이터베이스가 있습니다.

http://www.populardata.com

.CSV 파일을 믿지만 XML 파일로 쉽게 변환 할 수 있습니다.

다음은 입력 한 우편 번호를 기반으로 City.state Autofill을 수행하는 코드입니다.

<script type="text/javascript">//<![CDATA[
$(function() {
    // IMPORTANT: Fill in your client key
    var clientKey = "js-9qZHzu2Flc59Eq5rx10JdKERovBlJp3TQ3ApyC4TOa3tA8U7aVRnFwf41RpLgtE7";

    var cache = {};
    var container = $("#example1");
    var errorDiv = container.find("div.text-error");

    /** Handle successful response */
    function handleResp(data)
    {
        // Check for error
        if (data.error_msg)
            errorDiv.text(data.error_msg);
        else if ("city" in data)
        {
            // Set city and state
            container.find("input[name='city']").val(data.city);
            container.find("input[name='state']").val(data.state);
        }
    }

    // Set up event handlers
    container.find("input[name='zipcode']").on("keyup change", function() {
        // Get zip code
        var zipcode = $(this).val().substring(0, 5);
        if (zipcode.length == 5 && /^[0-9]+$/.test(zipcode))
        {
            // Clear error
            errorDiv.empty();

            // Check cache
            if (zipcode in cache)
            {
                handleResp(cache[zipcode]);
            }
            else
            {
                // Build url
                var url = "http://www.zipcodeapi.com/rest/"+clientKey+"/info.json/" + zipcode + "/radians";

                // Make AJAX request
                $.ajax({
                    "url": url,
                    "dataType": "json"
                }).done(function(data) {
                    handleResp(data);

                    // Store in cache
                    cache[zipcode] = data;
                }).fail(function(data) {
                    if (data.responseText && (json = $.parseJSON(data.responseText)))
                    {
                        // Store in cache
                        cache[zipcode] = json;

                        // Check for error
                        if (json.error_msg)
                            errorDiv.text(json.error_msg);
                    }
                    else
                        errorDiv.text('Request failed.');
                });
            }
        }
    }).trigger("change");
});

//]]>

여기 API가 있습니다. http://www.zipcodeapi.com/examples#example1.

XML을 통해 XML의 컨텐츠를 요청하면 XML에서 데이터를 직접 다시 가져 오십시오. 요청의 형식으로 .xml을 사용할 수 있습니다.

https://www.zipcodeapi.com/rest/rest/rbdapncxbjocvfcvcvcv4n5iwb3l4bezg017bfib2u9eoxqkmtqqgv9nxdyconconcencconcconcencencz/info.xml/90210/degrees

응답 할 것입니다

<response>
   <zip_code>90210</zip_code>
   <lat>34.100501</lat>
   <lng>-118.414908</lng>
   <city>Beverly Hills</city>
   <state>CA</state>
   <timezone>
   <timezone_identifier>America/Los_Angeles</timezone_identifier>
   <timezone_abbr>PDT</timezone_abbr>
      <utc_offset_sec>-25200</utc_offset_sec>
      <is_dst>T</is_dst>
   </timezone>
   <acceptable_city_names/>
</response>

API 문서가 있습니다 https://www.zipcodeapi.com/api

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top