My problem is that I have a search URL, that get an Xml code from an API.
The problem is that I have to make the webrequest to the Url over 20 times.
For that I made a for loop.
Expand|Select|Wrap|Line Numbers
- xdoc.LoadXml(xresponseFromServer);
- XmlNode xnodes = xdoc.SelectSingleNode("/Collection/articles");
- int mediaId = 0;
- int mediaListId = 0;
- string title = "";
- DateTime modified = DateTime.Parse("2000-01-01");
- CultureInfo CI = CultureInfo.CurrentCulture;
- CultureInfo readOnlyCI = CultureInfo.ReadOnly(CI);
- const DateTimeStyles Style = DateTimeStyles.AssumeLocal; // Assume it's local time.
- //int mediaIdCounter = 0;
- //int newMediaCounter = 0;
- int updateMediaCounter = 0;
- int deleteMediaCounter = 0;
- // Ensure that we are getting a list with at least one published movie.
- if (xn != null && xnodes.ChildNodes.Count > 0)
- {
- //set publishedAtProvider=2 for all movies.(later set publishedAtProvider=1 for all mediaId's found in XML. All that still have
- //published=2 after checking the list has been unpublished. Set PublishedAtProvider=0 for unpublished movies.
- //Create a new record for each new MediaId in the XML list.
- //setPublishStatusTwo(operatorCode, country, language);
- foreach (XmlNode node in xnodes.ChildNodes)
- {
- if (node.Name == "article")
- {
- // Loop through all Media from GetMediaList
- foreach (XmlNode childNode in node.ChildNodes)
- {
- if (childNode.LocalName.Equals("ExternalId"))
- {
- mediaId = Int32.Parse(childNode.InnerText);
- mediaIdCounter = ++mediaIdCounter;
- }
- else if (childNode.LocalName.Equals("title"))
- title = childNode.InnerText;
- else if (childNode.LocalName.Equals("modified"))
- modified = DateTime.Parse(childNode.InnerText, readOnlyCI, Style);
Thank you