private ArrayListDataSet ParseDocument(XmlDocument xDoc) { ArrayListDataSet trailers = new ArrayListDataSet(); XPathNavigator nav = xDoc.CreateNavigator(); if (nav.MoveToChild("records", "")) { XPathNodeIterator nIter = nav.SelectChildren("movieinfo", ""); nav.MoveToFirstChild(); XPathNavigator localNav = nav.CreateNavigator(); nav.MoveToParent(); for (int i = 0; i < nIter.Count; i++) { AppleTrailer currentTrailer = new AppleTrailer(); if (localNav.MoveToChild("info", "")) { currentTrailer.Copyright = GetChildNodesValue(localNav, "copyright"); currentTrailer.description = GetChildNodesValue(localNav, "description"); currentTrailer.Director = GetChildNodesValue(localNav, "director"); currentTrailer.Postdate = GetChildNodesValue(localNav, "postdate"); currentTrailer.Rating = GetChildNodesValue(localNav, "rating"); currentTrailer.ReleaseDate = GetChildNodesValue(localNav, "releasedate"); currentTrailer.Runtime = GetChildNodesValue(localNav, "runtime"); currentTrailer.Studio = GetChildNodesValue(localNav, "studio"); currentTrailer.Title = GetChildNodesValue(localNav, "title"); localNav.MoveToParent(); } if (localNav.MoveToChild("cast", "")) { XPathNodeIterator castIter = localNav.SelectChildren("name", ""); if (localNav.MoveToFirstChild()) { XPathNavigator castNav = localNav.CreateNavigator(); for (int j = 0; j < castIter.Count; j++) { currentTrailer.Actors.Add(castNav.Value); castNav.MoveToNext("name", ""); } localNav.MoveToParent(); } localNav.MoveToParent(); } if (localNav.MoveToChild("genre", "")) { XPathNodeIterator genreIter = localNav.SelectChildren("name", ""); if (localNav.MoveToFirstChild()) { XPathNavigator genreNav = localNav.CreateNavigator(); for (int k = 0; k < genreIter.Count; k++) { currentTrailer.Genres.Add(genreNav.Value); genreNav.MoveToNext("name", ""); } localNav.MoveToParent(); } localNav.MoveToParent(); } if (localNav.MoveToChild("poster", "")) { if (localNav.MoveToChild("location", "")) { currentTrailer.PosterUrl = localNav.Value; localNav.MoveToParent(); } if (localNav.MoveToChild("xlarge", "")) { currentTrailer.XLargePosterUrl = localNav.Value; localNav.MoveToParent(); } localNav.MoveToParent(); } if (localNav.MoveToChild("preview", "")) { if (localNav.MoveToChild(XPathNodeType.Element)) { currentTrailer.TrailerUrl = localNav.Value; currentTrailer.Filesize = localNav.GetAttribute("filesize", ""); localNav.MoveToParent(); } localNav.MoveToParent(); } trailers.Add(currentTrailer); localNav.MoveToNext(); } } return trailers; }
private ArrayListDataSet ParseDocument(XmlDocument xDoc) { ArrayListDataSet trailers = new ArrayListDataSet(); XPathNavigator nav = xDoc.CreateNavigator(); if (nav.MoveToChild("records", "")) { XPathNodeIterator nIter = nav.SelectChildren("movieinfo", ""); nav.MoveToFirstChild(); XPathNavigator localNav = nav.CreateNavigator(); nav.MoveToParent(); for (int i = 0; i < nIter.Count; i++) { AppleTrailer currentTrailer = new AppleTrailer(); if (localNav.MoveToChild("info", "")) { currentTrailer.Copyright = GetChildNodesValue(localNav, "copyright"); currentTrailer.description = GetChildNodesValue(localNav, "description"); currentTrailer.Director = GetChildNodesValue(localNav, "director"); currentTrailer.Postdate = GetChildNodesValue(localNav, "postdate"); currentTrailer.Rating = GetChildNodesValue(localNav, "rating"); currentTrailer.ReleaseDate = GetChildNodesValue(localNav, "releasedate"); currentTrailer.Runtime = GetChildNodesValue(localNav, "runtime"); currentTrailer.Studio = GetChildNodesValue(localNav, "studio"); currentTrailer.Title = GetChildNodesValue(localNav, "title"); localNav.MoveToParent(); } if (localNav.MoveToChild("cast", "")) { XPathNodeIterator castIter = localNav.SelectChildren("name", ""); if (localNav.MoveToFirstChild()) { XPathNavigator castNav = localNav.CreateNavigator(); for (int j = 0; j < castIter.Count; j++) { currentTrailer.Actors.Add(castNav.Value); castNav.MoveToNext("name", ""); } localNav.MoveToParent(); } localNav.MoveToParent(); } if (localNav.MoveToChild("genre", "")) { XPathNodeIterator genreIter = localNav.SelectChildren("name", ""); if (localNav.MoveToFirstChild()) { XPathNavigator genreNav = localNav.CreateNavigator(); for (int k = 0; k < genreIter.Count; k++) { currentTrailer.Genres.Add(genreNav.Value); genreNav.MoveToNext("name", ""); } localNav.MoveToParent(); } localNav.MoveToParent(); } if (localNav.MoveToChild("poster", "")) { if (localNav.MoveToChild("location", "")) { currentTrailer.PosterUrl = localNav.Value; localNav.MoveToParent(); } if (localNav.MoveToChild("xlarge", "")) { currentTrailer.XLargePosterUrl = localNav.Value; localNav.MoveToParent(); } localNav.MoveToParent(); } if (localNav.MoveToChild("preview", "")) { if (localNav.MoveToChild(XPathNodeType.Element)) { currentTrailer.TrailerUrl = localNav.Value; currentTrailer.Filesize = localNav.GetAttribute("filesize", ""); localNav.MoveToParent(); } localNav.MoveToParent(); } trailers.Add(currentTrailer); localNav.MoveToNext(); } } return(trailers); }