0

Web ホスティングを適切な 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 を使用します。

4

4 に答える 4

1

これをチェックしてください。いくつかの異なる無料のものを提供しています。

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

于 2009-01-10T19:50:30.607 に答える
0

入力された郵便番号に基づいて city.state 自動入力を行うコードを次に示します。

<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

于 2016-09-09T15:40:02.077 に答える
0

無料の郵便番号データベースが次の場所にあります。

http://www.populardata.com

.CSV ファイルだと思いますが、XML ファイルに簡単に変換できます。

于 2009-06-03T04:43:04.550 に答える
0

XML でコンテンツをリクエストできます。データを XML で直接取得するには、リクエストの形式で .xml を使用できます。

https://www.zipcodeapi.com/rest/RbdapNcxbjoCvfCv4N5iwB3L4beZg017bfiB2u9eOxQkMtQQgV9NxdyCoNCENDMZ/info.xml/90210/度

で応答します

<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にあります。

于 2016-09-12T16:04:39.250 に答える