public OldParserSynchronizer(EnhancedXmlParser enhancedXmlParser, IXmlTagParsingStrategy parsingStrategy, XmlParser oldParser) { this.enhancedXmlParser = enhancedXmlParser; this.oldParser = oldParser; this.parsingStrategy = parsingStrategy; enhancedXmlParser.MoveOldParserToCurrentTag(oldParser); }
/// <summary> /// remove the specified elements from the XML buffer /// </summary> /// <param name="xmlBuffer">The XML buffer to change</param> /// <param name="elementTagsToRemove">Array of strings (=element tags) to remove from the buffer</param> /// <returns></returns> public static String RemoveXmlElements(String xmlBuffer, params string[] elementTagsToRemove) { EnhancedXmlParser parser = new EnhancedXmlParser(); // Go over all tags to be removed foreach (String tagToRemove in elementTagsToRemove) { StringBuilder returnedXml = new StringBuilder(); parser.SetXMLData(xmlBuffer); int startIndex = 0; // loop while the requested tag exists in the XML buffer while (parser.MoveToElement(tagToRemove)) { // read the string up to the tag returnedXml.Append(xmlBuffer.Substring(startIndex, parser.CurrentPosition - startIndex)); // skip the element using the parser to find the end of the tag parser.ReadToEndOfCurrentElement(); startIndex = parser.CurrentPosition; } // add what remained after the last removed tag returnedXml.Append(xmlBuffer.Substring(startIndex)); //prepare the buffer for the next tag to remove xmlBuffer = returnedXml.ToString(); } return(xmlBuffer); }
public bool Deserialize(EnhancedXmlParser parser) { using (parser.ElementBoundary()) { if (!EnterElement(parser)) { return(false); } while (parser.MoveToNextTag(GetTagParsingStrategy())) { if (!parser.IsOnElementClosingTag) { if (!ProcessInnerElement(parser)) { Logger.Instance.WriteErrorToLog("An error occurred while deserializing an object. See previous messages for more details."); return(false); } } } if (!LeaveElement(parser)) { return(false); } } return(true); }
public ParserContextSwitch(EnhancedXmlParser parser) { this.parser = parser; }
protected virtual bool ProcessInnerElement(EnhancedXmlParser parser) { return(true); }
protected virtual bool LeaveElement(EnhancedXmlParser parser) { return(true); }