Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- //list that contain all the cities & their streets
- //
- List<city_details> list_of_cities = new List<city_details>();
- //
- //index for the loop that adding the streets & the cities to the list
- //
- int index = 0;
- private void Form1_Load(object sender, EventArgs e)
- {
- //
- //new xml object
- //
- XmlDocument xml = new XmlDocument();
- xml.Load(@"rechov.xml");
- //
- //
- //
- foreach (XmlNode node in xml.SelectNodes("ROWDATA/ROW"))
- {
- //
- //if the list is empty - add new city and new street, and ncrease the index in one.
- //
- if (list_of_cities.Count == 0)
- {
- list_of_cities.Add(new city_details(node.SelectSingleNode("city_name").InnerText, node.SelectSingleNode("street_name").InnerText));
- index++;
- }
- //
- //if its not empty -
- //
- else
- {
- //
- //if this city and the previous city they not the same city
- //
- if ((node.SelectSingleNode("city_name").InnerText != list_of_cities[index - 1].city))
- {
- //
- // add a new city & a new stret, and increase the index in one
- //
- list_of_cities.Add(new city_details(node.SelectSingleNode("city_name").InnerText, node.SelectSingleNode("street_name").InnerText));
- index++;
- }
- //
- //if they same city
- //
- else
- {
- //
- //just add a new street
- //
- list_of_cities[index - 1].street.Add(node.SelectSingleNode("street_name").InnerText);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement