| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Web;
- using System.Xml;
- namespace CD67.FicheCollege.MVC.Internal
- {
- public class Referentiel
- {
- /// <summary>
- /// Fonction qui interroge l'index SolR du référentiel commune pour retourner les codes postaux par communes
- /// </summary>
- /// <param name="Insee">Code Insee de la commune souhaitée</param>
- /// <returns>Liste des codes postaux possibles</returns>
- public static List<string> GetCodesPostaux(string Insee)
- {
- //cas de sortie immédiat
- if (Insee == null) return new List<string>();
- var m_strFilePath = String.Format(Properties.Settings.Default.GetCodesPostaux_URL, Insee);
- string xmlStr;
- using (var wc = new WebClient())
- {
- xmlStr = wc.DownloadString(m_strFilePath);
- }
- var xmlDoc = new XmlDocument();
- xmlDoc.LoadXml(xmlStr);
- //Recherche des données
- List<string> result = new List<string>();
- foreach (XmlNode item in xmlDoc.GetElementsByTagName("str"))
- {
- result.Add(item.InnerText);
- }
- return result;
- }
- }
- }
|