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 { /// /// Fonction qui interroge l'index SolR du référentiel commune pour retourner les codes postaux par communes /// /// Code Insee de la commune souhaitée /// Liste des codes postaux possibles public static List GetCodesPostaux(string Insee) { //cas de sortie immédiat if (Insee == null) return new List(); 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 result = new List(); foreach (XmlNode item in xmlDoc.GetElementsByTagName("str")) { result.Add(item.InnerText); } return result; } } }