public bool MoveNext() { bool bResult = true; if (OnixDoc == null) { this.OnixDoc = new XmlDocument(); this.OnixDoc.Load(this.OnixReader); this.ProductList = this.OnixDoc.GetElementsByTagName(this.ProductXmlTag); } if (++CurrentIndex < this.ProductList.Count) { string sInputXml = this.ProductList[CurrentIndex].OuterXml; try { CurrentRecord = this.ProductSerializer.Deserialize(new StringReader(sInputXml)) as OnixProduct; CurrentCommList.Clear(); if ((CurrentRecord.CollateralDetail != null) && (CurrentRecord.CollateralDetail.OnixTextContentList != null) && (CurrentRecord.CollateralDetail.OnixTextContentList.Length > 0)) { CurrentCommList.AddRange(CurrentRecord.CollateralDetail.OnixTextContentList); } } catch (Exception ex) { CurrentRecord = new OnixProduct(); CurrentRecord.SetParsingError(ex); CurrentRecord.SetInputXml(sInputXml); } } else { bResult = false; } return(bResult); }
public bool MoveNext() { bool bResult = true; if (OnixDoc == null) { this.OnixDoc = new XmlDocument(); this.OnixDoc.Load(this.OnixReader); this.ProductList = this.OnixDoc.GetElementsByTagName(this.ProductXmlTag); } if (++CurrentIndex < this.ProductList.Count) { string sInputXml = this.ProductList[CurrentIndex].OuterXml; // NOTE: This section will remove any problematic control characters which are not allowed within XML string sControlCharDomain = "[\x00-\x08\x0B\x0C\x0E-\x1F\x26]"; string sFilteredInputXml = System.Text.RegularExpressions.Regex.Replace(sInputXml, sControlCharDomain, "", System.Text.RegularExpressions.RegexOptions.Compiled); try { CurrentRecord = this.ProductSerializer.Deserialize(new StringReader(sFilteredInputXml)) as OnixProduct; } catch (Exception ex) { CurrentRecord = new OnixProduct(); CurrentRecord.SetParsingError(ex); CurrentRecord.SetInputXml(sInputXml); } } else { bResult = false; } return(bResult); }