public void NodeReaderMoveToElementWithSimpleXml() { string xml = "<root attr='cal'><child attr='val'><inner attr='val'></inner></child></root>"; XmlNodeReader nodeReader = NodeReaderTestHelper.CreateNodeReader(xml); Assert.True(nodeReader.Read()); nodeReader.MoveToFirstAttribute(); Assert.True(nodeReader.MoveToElement()); Assert.True(nodeReader.MoveToAttribute("attr")); nodeReader.ReadContentAsBase64(new byte[33], 10, 10); Assert.True(nodeReader.MoveToElement()); }
public static void Main() { XmlNodeReader reader = null; try { //Create and load the XML document. XmlDocument doc = new XmlDocument(); doc.LoadXml("<book genre='novel' ISBN='1-861003-78' publicationdate='1987'> " + "</book>"); //Load the XmlNodeReader reader = new XmlNodeReader(doc); //Read the attributes on the root element. reader.MoveToContent(); if (reader.HasAttributes){ for (int i=0; i<reader.AttributeCount; i++){ reader.MoveToAttribute(i); Console.WriteLine("{0} = {1}", reader.Name, reader.Value); } //Return the reader to the book element. reader.MoveToElement(); } } finally { if (reader != null) reader.Close(); } }
public void NodeReaderMoveToElementWithEmptyXml() { var xmlDoc = new XmlDocument(); var nodeReader = new XmlNodeReader(xmlDoc); Assert.False(nodeReader.MoveToElement()); }
private void readConfigFile() { string[] config = new string[5]; int i = 0; //Create xml object XmlDocument xmlDOC = new XmlDocument(); xmlDOC.Load("config.xml"); XmlNodeReader readXML = new XmlNodeReader(xmlDOC); while (readXML.Read()) { readXML.MoveToElement(); //Forward if (readXML.NodeType == XmlNodeType.Text) //Only save config { config[i] = readXML.Value; i++; } } accessKeyId.Text = config[0]; accessKeySecret.Text = config[1]; recordId.Text = config[2]; fullDomainName.Text = config[3]; nextUpdateSeconds.Text = newSeconds.Text = config[4]; }
public override bool MoveToElement() { if (IsXmlDataNode) { return(_xmlNodeReader.MoveToElement()); } if (_nodeType != XmlNodeType.Attribute) { return(false); } SetElement(); return(true); }
private List <string> GetPageLinks(XmlDocument doc) { List <string> links = new List <string>(); XmlReader reader = new XmlNodeReader(doc); // Look for <loc> and <a> tags while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name.ToLower() == "loc") { if (reader.Read() && IsLinkAllowed(reader.Value)) { links.Add(reader.Value.ToLower().Trim()); } } else if (reader.Name.ToLower() == "a") { if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { if (reader.Name.ToLower() == "href") { string URL = reader.Value.ToLower(); if (URL[0] == '/') { // Append relative path to domain URL = crawlURL + URL.Substring(1, URL.Length - 1); } if (IsLinkAllowed(URL)) { links.Add(URL); } } break; } reader.MoveToElement(); } } } } return(links); }
/// <summary> /// Parses an IM log file and sends the information to GDS /// </summary> /// <param name="logFile">The IM conversations log file</param> /// <param name="lastIndexed">messages older than this will not be sent to GDS</param> private void ParseAndSendMessages(string logFile, DateTime lastIndexed) { XmlDocument doc = new XmlDocument(); doc.Load(logFile); XmlNodeReader reader = new XmlNodeReader(doc); // reset user and buddy name userName = null; buddyName = null; // Moves the reader to the root element. reader.MoveToContent(); // move to the first message reader.Read(); while (reader.LocalName == "Message") { // check the date of the message - if older skip reader.MoveToAttribute("DateTime"); DateTime messageDateTime = DateTime.Parse(reader.Value); reader.MoveToElement(); // if older than the last indexing time, skip the message if (messageDateTime.CompareTo(lastIndexed) <= 0) { reader.Skip(); continue; } // get message data MSNMessageData messageData = ParseMessageData(reader.ReadOuterXml()); // send this message to GDS for indexing SendMessageData(messageData); } }
public ConfigurationManager(String xmlConfigFileName) { configFullFileName = xmlConfigFileName; // Open the configuration document XmlDocument xmlConfigStruct = new XmlDocument(); xmlConfigStruct.Load(xmlConfigFileName); // Get reader reference XmlNodeReader reader = new XmlNodeReader(xmlConfigStruct); // Initialize error supress array. Default is error enabled errSupressArr = new int[Enum.GetValues(typeof(ErrorCode)).Length]; for (int i = 0; i < errSupressArr.Length; i++) { errSupressArr[i] = Logger.NOT_SUPRESS_ERR_CODE; } // Parse the xml file while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "ConfigurationParameter" || reader.Name == "Configuration") { if (reader.HasAttributes) { // Read attibutes using linked list of attributes while (reader.MoveToNextAttribute()) { switch (reader.Name) { case "LogFile": logFile = new StreamWriter(File.Open(reader.Value, FileMode.OpenOrCreate, FileAccess.Write), Encoding.Unicode); logFile.AutoFlush = true; break; case "RootTrainDirectory": rootTrainDirectory = reader.Value; break; case "RootTestDirectory": rootTestDirectory = reader.Value; break; case "ConfigurationEnvironmentDirectory": configEnvDirectory = reader.Value; break; case "MrfFolderName": mrfFolderName = reader.Value; break; case "PosFolderName": posFolderName = reader.Value; break; case "DirectorySeparator": directorySeparator = reader.Value; break; case "FileExensionSeparator": fileExtensionSeparator = reader.Value; break; case "MrfFileExtension": mrfFileExtension = reader.Value; break; case "POSFileExtension": posFileExtension = reader.Value; break; case "DebugMode": debugMode = bool.Parse(reader.Value); break; case "ErrorLogMode": errorLogMode = bool.Parse(reader.Value); break; case "ConsoleLogMode": consoleLogMode = bool.Parse(reader.Value); break; case "SuppressErrType": try { errSupressArr[Int32.Parse(reader.Value) - 1] = Logger.SUPRESS_ERR_CODE; } catch (IndexOutOfRangeException e) { Console.WriteLine("Incorrect configuration parameter. Error type code is out of range. Please provide code less than " + Enum.GetValues(typeof(ErrorCode)).Length); throw (e); } break; case "FeaturesFormat": featuresFormat = reader.Value; break; case "MatlabFunctionName": matlabOutFileName = "DCONV_convertMatlabInput_" + featuresFormat + ".m"; break; case "MatlabFilePath": matlabOutFilePath = reader.Value; break; case "OutputFeatures": outputFeatures = reader.Value; break; case "OutputFile": // Either Encoding.Default of leave empty otherwise MATLAB will not understand the lines: extrac characters are added outputFile = new StreamWriter(File.Open(reader.Value + "_" + featuresFormat + ".txt", FileMode.OpenOrCreate, FileAccess.Write), Encoding.Default); break; case "OutputFileFormat": outputFileFormat = reader.Value; break; case "ContextType": // Type 1 (considering before and after fixed num. of words) or Type 2 (considering context length with no constraint on before and after) contextType = reader.Value; break; case "ContextBeforeLength": // Type 1 contextBeforeLength = Int32.Parse(reader.Value); break; case "ContextAfterLength": // Type 1 contextAfterLength = Int32.Parse(reader.Value); break; case "ContextLength": // Type 2 contextLength = Int32.Parse(reader.Value); break; case "LastCharFeaturesDepth": lastCharFeaturesDepth = Int32.Parse(reader.Value); break; default: Console.WriteLine("Incorrect configuration parameter." + reader.Value + " is invalid value for Configuration Parameter" + reader.Name); break; } // end switch (reader.Name) } // end while (reader.MoveToNextAttribute()) } // end if (reader.HasAttributes) // Get back to root element reader.MoveToElement(); }// end if (reader.NodeType == XmlNodeType.Element) else { Console.WriteLine("Incorrect configuration parameter. Expected: ConfigurationParameter, Found: " + reader.Name); } } }// end of while (reader.Read()) }
private abstract_Element process_element(XmlNodeReader nodeReader, int current_page_count) { string type = String.Empty; string subtype = String.Empty; // Step through all the attributes until the type is found nodeReader.MoveToFirstAttribute(); do { // Get the type attribute if (nodeReader.Name.ToUpper().Trim() == "TYPE") { type = nodeReader.Value; } // Get the subtype attribute if (nodeReader.Name.ToUpper().Trim() == "SUBTYPE") { subtype = nodeReader.Value; } } while (nodeReader.MoveToNextAttribute()); // Make sure a type was specified if (type == String.Empty) { return(null); } // Build the element abstract_Element newElement = Element_Factory.getElement(type, subtype); // If thie element was null, return null if (newElement == null) { return(null); } // Set the page number for post back reasons newElement.Template_Page = current_page_count; // Some special logic here if ((newElement.Type == Element_Type.Type) && (newElement.Display_SubType == "form")) { (( Type_Format_Form_Element )newElement).Set_Postback("javascript:__doPostBack('newpagebutton" + current_page_count + "','')"); } if ((newElement.Type == Element_Type.Title) && (newElement.Display_SubType == "form")) { complexMainTitleExists = true; } if ((newElement.Type == Element_Type.Note) && (newElement.Display_SubType == "complex")) { ((Note_Complex_Element)newElement).Include_Statement_Responsibility = !complexMainTitleExists; } // Now, step through all the attributes again nodeReader.MoveToFirstAttribute(); do { switch (nodeReader.Name.ToUpper().Trim()) { case "REPEATABLE": bool repeatable; if (Boolean.TryParse(nodeReader.Value, out repeatable)) { newElement.Repeatable = repeatable; } break; case "MANDATORY": bool mandatory; if (Boolean.TryParse(nodeReader.Value, out mandatory)) { newElement.Mandatory = mandatory; } break; case "READONLY": bool isReadOnly; if (Boolean.TryParse(nodeReader.Value, out isReadOnly)) { newElement.Read_Only = isReadOnly; } break; case "ACRONYM": newElement.Acronym = nodeReader.Value; break; } } while (nodeReader.MoveToNextAttribute()); // Move back to the element, if there were attributes (should be) nodeReader.MoveToElement(); // Is there element_data? if (!nodeReader.IsEmptyElement) { nodeReader.Read(); if ((nodeReader.NodeType == XmlNodeType.Element) && (nodeReader.Name.ToLower() == "element_data")) { // Create the new tree StringWriter sw = new StringWriter(); XmlTextWriter tw = new XmlTextWriter(sw); tw.WriteNode(nodeReader, true); tw.Close(); // Let the element process this inner data newElement.Read_XML(new XmlTextReader(new StringReader(sw.ToString()))); } } // Return this built element return(newElement); }
private abstract_Element process_element(XmlNodeReader nodeReader, int current_page_count) { string type = String.Empty; string subtype = String.Empty; // Step through all the attributes until the type is found nodeReader.MoveToFirstAttribute(); do { // Get the type attribute if (nodeReader.Name.ToUpper().Trim() == "TYPE") { type = nodeReader.Value; } // Get the subtype attribute if (nodeReader.Name.ToUpper().Trim() == "SUBTYPE") { subtype = nodeReader.Value; } } while (nodeReader.MoveToNextAttribute()); // Make sure a type was specified if (type == String.Empty) { return(null); } // Build the element abstract_Element newElement = Element_Factory.getElement(type, subtype); // If thie element was null, return null if (newElement == null) { return(null); } // Set the page number for post back reasons newElement.Template_Page = current_page_count; // Now, step through all the attributes again nodeReader.MoveToFirstAttribute(); do { switch (nodeReader.Name.ToUpper().Trim()) { case "REPEATABLE": bool repeatable; if (Boolean.TryParse(nodeReader.Value, out repeatable)) { newElement.Repeatable = repeatable; } break; case "MANDATORY": bool mandatory; if (Boolean.TryParse(nodeReader.Value, out mandatory)) { newElement.Mandatory = mandatory; } break; case "READONLY": bool isReadOnly; if (Boolean.TryParse(nodeReader.Value, out isReadOnly)) { newElement.Read_Only = isReadOnly; } break; case "ACRONYM": newElement.Acronym = nodeReader.Value; break; } } while (nodeReader.MoveToNextAttribute()); // Move back to the element, if there were attributes (should be) nodeReader.MoveToElement(); // Is there element_data? if (!nodeReader.IsEmptyElement) { nodeReader.Read(); if ((nodeReader.NodeType == XmlNodeType.Element) && (nodeReader.Name.ToLower() == "element_data")) { // Let the element process this inner data newElement.Read_XML(nodeReader.ReadSubtree()); } } // Return this built element return(newElement); }
/// <summary> /// Writes the XML. /// </summary> /// <param name="xmlDocument">The XML document.</param> private void WriteXml(XmlDocument xmlDocument) { XmlNodeReader reader = null; try { //Create an XmlNodeReader to read the XmlDocument. reader = new XmlNodeReader(xmlDocument); //Parse the file and display each of the nodes. while (reader.Read()) { UpdateLevel(reader.Depth); //Write("{0}", reader.Depth.ToString("00")); switch (reader.NodeType) { case XmlNodeType.Element: if (_currentNodeName != string.Empty) { WriteLine(); } _currentNodeName = reader.Name; Write("<{0}", reader.Name); if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { Write(" {0}=\"{1}\"", reader.Name, reader.Value); } Write(" "); // Move the reader back to the element node. reader.MoveToElement(); } Write(reader.IsEmptyElement ? "/>" : ">"); if (reader.IsEmptyElement) { _currentNodeName = string.Empty; WriteLine(); } break; case XmlNodeType.EndElement: if (_currentNodeName == reader.Name) { _currentNodeName = string.Empty; } WriteLine("</{0}>", reader.Name); break; case XmlNodeType.Text: Write(reader.Value); break; case XmlNodeType.CDATA: Write(reader.Value); break; case XmlNodeType.ProcessingInstruction: case XmlNodeType.XmlDeclaration: WriteLine("<?{0} {1}?>", reader.Name, reader.Value); break; case XmlNodeType.Comment: WriteLine("<!--{0}-->", reader.Value); break; case XmlNodeType.Document: break; default: WriteLine(); WriteLine("ERROR: Unexpected node type ({0}) encountered", reader.NodeType); WriteLine(); break; } } } finally { if (reader != null) { reader.Close(); } } }
private abstract_Element process_element(XmlNodeReader nodeReader) { string type = String.Empty; string subtype = String.Empty; // Step through all the attributes until the type is found nodeReader.MoveToFirstAttribute(); do { // Get the type attribute if (nodeReader.Name.ToUpper().Trim() == "TYPE") { type = nodeReader.Value; } // Get the subtype attribute if (nodeReader.Name.ToUpper().Trim() == "SUBTYPE") { subtype = nodeReader.Value; } } while (nodeReader.MoveToNextAttribute()); // Make sure a type was specified if (type == String.Empty) { return(null); } // Build the element abstract_Element newElement = Element_Factory.getElement(type, subtype); // Some special code to make the creator element aware if there is a contributor element if ((newElement.Type == Element_Type.Creator) && (newElement.Display_SubType == "simple")) { creatorSimpleElement = (Creator_Simple_Element)newElement; } if ((newElement.Type == Element_Type.Contributor) && (creatorSimpleElement != null)) { creatorSimpleElement.Contributor_Exists = true; } // Some special code to let the simple subject element know if there is a simple spatial element if ((newElement.Type == Element_Type.Subject) && ((newElement.Display_SubType == "simple") || (newElement.Display_SubType == "dublincore"))) { if (spatialSimpleElement != null) { ((Subject_Simple_Element)newElement).Seperate_Dublin_Core_Spatial_Exists = true; } else { subjectSimpleElement = (Subject_Simple_Element)newElement; } } if ((newElement.Type == Element_Type.Spatial) && (newElement.Display_SubType == "dublincore")) { if (subjectSimpleElement != null) { subjectSimpleElement.Seperate_Dublin_Core_Spatial_Exists = true; } else { spatialSimpleElement = (Spatial_Simple_Element)newElement; } } // Now, step through all the attributes again nodeReader.MoveToFirstAttribute(); do { try { switch (nodeReader.Name.ToUpper().Trim()) { case "X": newElement.Location = new Point(Convert.ToInt16(nodeReader.Value), newElement.Location.Y); break; case "Y": newElement.Location = new Point(newElement.Location.X, Convert.ToInt16(nodeReader.Value)); break; case "HEIGHT": newElement.Height = Convert.ToInt16(nodeReader.Value); break; case "WIDTH": newElement.Width = Convert.ToInt16(nodeReader.Value); break; case "REPEATABLE": newElement.Repeatable = Convert.ToBoolean(nodeReader.Value); break; case "MANDATORY": newElement.Mandatory = Convert.ToBoolean(nodeReader.Value); break; } } catch { } } while (nodeReader.MoveToNextAttribute()); // Move back to the element, if there were attributes (should be) nodeReader.MoveToElement(); // Is there element_data? if (!nodeReader.IsEmptyElement) { nodeReader.Read(); if ((nodeReader.NodeType == XmlNodeType.Element) && (nodeReader.Name.ToLower() == "element_data")) { // Create the new tree StringWriter sw = new StringWriter(); XmlTextWriter tw = new XmlTextWriter(sw); tw.WriteNode(nodeReader, true); tw.Close(); // Let the element process this inner data newElement.Read_XML(new XmlTextReader(new StringReader(sw.ToString()))); } } // If this is the METS ObjectID, suppress it if the SobekCM add-on is enabled if ((newElement.Type == Element_Type.METS_ObjectID) && (addonsEnabled.Contains("SOBEKCM"))) { return(null); } // Return this built element return(newElement); }
private void ExecuteSection(XmlNode section) { using (XmlNodeReader readerXML = new XmlNodeReader(section)) { try { Dictionary <String, String> actionParameters = new Dictionary <String, String>(); while (readerXML.Read()) { actionParameters.Clear(); while (readerXML.MoveToNextAttribute()) { actionParameters.Add(readerXML.Name, readerXML.Value); } readerXML.MoveToElement(); switch (readerXML.NodeType) { case XmlNodeType.Element: switch (readerXML.Name) { case "True": if (!_activeRuleSets.Peek().EngineState.ConditionalStack.Peek()) { readerXML.Skip(); } break; case "False": if (_activeRuleSets.Peek().EngineState.ConditionalStack.Peek()) { readerXML.Skip(); } break; case "Optional": if (MessageBox.Show(String.Format("Would you like to process {0} optional section?", actionParameters.ContainsKey("Name") ? actionParameters["Name"] : "the following"), "Optional Section Execution Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.No) { readerXML.Skip(); } break; default: ExecuteElementStartRule(readerXML.Name, actionParameters); break; } break; case XmlNodeType.EndElement: switch (readerXML.Name) { case "True": case "False": case "Optional": break; default: ExecuteElementEndRule(readerXML.Name); break; } break; } } } catch (Exception ex) { } } }
public ConfigurationManager(String xmlConfigFileName) { configFullFileName = xmlConfigFileName; // Open the configuration document XmlDocument xmlConfigStruct = new XmlDocument(); xmlConfigStruct.Load(xmlConfigFileName); // Get reader reference XmlNodeReader reader = new XmlNodeReader(xmlConfigStruct); // Initialize error supress array. Default is error enabled errSupressArr = new int[Enum.GetValues(typeof(ErrorCode)).Length]; for (int i = 0; i < errSupressArr.Length; i++) { errSupressArr[i] = Logger.NOT_SUPRESS_ERR_CODE; } currPOSTagger = -1; // Parse the xml file while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "ConfigurationParameter" || reader.Name == "Configuration") { if (reader.HasAttributes) { // Read attibutes using linked list of attributes while (reader.MoveToNextAttribute()) { switch (reader.Name) { case "LogFile": try { logFile = new StreamWriter(File.Open(configEnvDirectory + "\\" + reader.Value, FileMode.OpenOrCreate, FileAccess.Write), Encoding.Unicode); logFile.AutoFlush = true; } catch { break; } break; case "RootTrainDirectory": rootTrainDirectory = reader.Value; break; case "RootTestDirectory": rootTestDirectory = reader.Value; break; case "ConfigurationEnvironmentDirectory": configEnvDirectory = reader.Value; try { File.Copy(configFullFileName, configEnvDirectory + "\\" + configFullFileName.Split("\\".ToCharArray()).Last(), true); } catch { break; } break; case "MrfFolderName": mrfFolderName = reader.Value; break; case "PosFolderName": posFolderName = reader.Value; break; case "TxtFolderName": txtFolderName = reader.Value; break; case "DirectorySeparator": directorySeparator = reader.Value; break; case "FileExensionSeparator": fileExtensionSeparator = reader.Value; break; case "MrfFileExtension": mrfFileExtension = reader.Value; break; case "POSFileExtension": posFileExtension = reader.Value; break; case "TxtFileExtension": txtFileExtension = reader.Value; break; case "DebugMode": debugMode = bool.Parse(reader.Value); break; case "ErrorLogMode": errorLogMode = bool.Parse(reader.Value); break; case "ConsoleLogMode": consoleLogMode = bool.Parse(reader.Value); break; case "SuppressErrType": try { errSupressArr[Int32.Parse(reader.Value) - 1] = Logger.SUPRESS_ERR_CODE; } catch (IndexOutOfRangeException e) { Console.WriteLine("Incorrect configuration parameter. Error type code is out of range. Please provide code less than " + Enum.GetValues(typeof(ErrorCode)).Length); throw (e); } break; case "FeaturesFormat": featuresFormat = reader.Value; break; case "MatlabFunctionName": matlabOutFileName = "DCONV_convertMatlabInput_" + featuresFormat + ".m"; break; case "MatlabFilePath": matlabOutFilePath = reader.Value; break; case "OutputFeatures": outputFeatures = reader.Value; break; case "OutputFile": // Either Encoding.Default of leave empty otherwise MATLAB will not understand the lines: extrac characters are added try { outputFile = new StreamWriter(File.Open(configEnvDirectory + "\\" + reader.Value + "_" + featuresFormat + ".txt", FileMode.OpenOrCreate, FileAccess.Write), Encoding.Default); } catch { break; } break; case "OutputFileFormat": outputFileFormat = reader.Value; break; case "ContextType": // Type 1 (considering before and after fixed num. of items) or Type 2 (considering context length with no constraint on before and after) contextType = reader.Value; break; case "ContextBeforeLength": // Type 1 contextBeforeLength = Int32.Parse(reader.Value); break; case "ContextAfterLength": // Type 1 contextAfterLength = Int32.Parse(reader.Value); break; case "ContextTargetBeforeLength": // Type 1 contextTargetBeforeLength = Int32.Parse(reader.Value); break; case "ContextTargetAfterLength": // Type 1 contextTargetAfterLength = Int32.Parse(reader.Value); break; case "CentralWordContextBeforeLength": // Type 1 centralWordContextBeforeLength = Int32.Parse(reader.Value); break; case "CentralWordContextAfterLength": // Type 1 centralWordContextAfterLength = Int32.Parse(reader.Value); break; case "ContextLength": // Type 2 contextLength = Int32.Parse(reader.Value); break; case "LastCharFeaturesDepth": lastCharFeaturesDepth = Int32.Parse(reader.Value); break; case "SuppressFeature": suppressFeaturesHashTable.Add(reader.Value, "Suppress"); break; case "SuppressTarget": suppressTargetsHashTable.Add(reader.Value, "Suppress"); break; case "AddFeatureToCentralContextWord": addFeaturesToCentralContextWord.Add(reader.Value, "Add"); break; case "TrainInputFormat": trainInputFormat = reader.Value; break; case "TestInputFormat": testInputFormat = reader.Value; break; case "NumberPOSTaggers": numPOSTaggers = Int32.Parse(reader.Value); posTaggersParams = new POSTaggerParams[numPOSTaggers]; break; case "POSTaggerName": currPOSTagger++; //numPOSTaggers = 1; posTaggersParams[currPOSTagger] = new POSTaggerParams(); posTaggersParams[currPOSTagger].posTaggerName = reader.Value; break; case "POSTaggerType": try { posTaggersParams[currPOSTagger].posTaggerType = reader.Value; } catch { currPOSTagger++; numPOSTaggers = 1; posTaggersParams = new POSTaggerParams[1]; posTaggersParams[0] = new POSTaggerParams(); posTaggersParams[0].posTaggerType = reader.Value; } break; case "StanfordRemoveDiacritics": try { posTaggersParams[currPOSTagger].stanfordRemoveDiacritics = bool.Parse(reader.Value); } catch { currPOSTagger++; numPOSTaggers = 1; posTaggersParams = new POSTaggerParams[1]; posTaggersParams[0] = new POSTaggerParams(); posTaggersParams[0].stanfordRemoveDiacritics = bool.Parse(reader.Value); } break; case "StanfordTaggerModelName": try { posTaggersParams[currPOSTagger].stanfordTaggerModelName = reader.Value; } catch { currPOSTagger++; numPOSTaggers = 1; posTaggersParams = new POSTaggerParams[1]; posTaggersParams[0] = new POSTaggerParams(); posTaggersParams[0].stanfordTaggerModelName = reader.Value; } break; case "StanfordTaggerOutFileName": try { posTaggersParams[currPOSTagger].stanfordTaggerOutFileName = reader.Value; } catch { currPOSTagger++; numPOSTaggers = 1; posTaggersParams = new POSTaggerParams[1]; posTaggersParams[0] = new POSTaggerParams(); posTaggersParams[0].stanfordTaggerOutFileName = reader.Value; } break; case "StanfordFileWithoutDiacs": try { posTaggersParams[currPOSTagger].stanfordFileWithoutDiacs = reader.Value; } catch { currPOSTagger++; numPOSTaggers = 1; posTaggersParams = new POSTaggerParams[1]; posTaggersParams[0] = new POSTaggerParams(); posTaggersParams[0].stanfordFileWithoutDiacs = reader.Value; } break; case "MapStanfordToRDI": try { posTaggersParams[currPOSTagger].stanfordMapStanfordToRDI = bool.Parse(reader.Value); } catch { currPOSTagger++; numPOSTaggers = 1; posTaggersParams = new POSTaggerParams[1]; posTaggersParams[0] = new POSTaggerParams(); posTaggersParams[0].stanfordMapStanfordToRDI = bool.Parse(reader.Value); } break; case "FinalNetFullPath": try { posTaggersParams[currPOSTagger].DNN_POSTaggerFinalNetFullPath = reader.Value; } catch { currPOSTagger++; numPOSTaggers = 1; posTaggersParams = new POSTaggerParams[1]; posTaggersParams[0] = new POSTaggerParams(); posTaggersParams[0].DNN_POSTaggerMaxIDInfoFileFullPath = reader.Value; } break; case "MaxIDInfoFileFullPath": try { posTaggersParams[currPOSTagger].DNN_POSTaggerMaxIDInfoFileFullPath = reader.Value; } catch { currPOSTagger++; numPOSTaggers = 1; posTaggersParams = new POSTaggerParams[1]; posTaggersParams[0] = new POSTaggerParams(); posTaggersParams[0].DNN_POSTaggerMaxIDInfoFileFullPath = reader.Value; } break; case "ConfigurationFileFullPath": try { posTaggersParams[currPOSTagger].DNN_POSTaggerConfigurationFileFullPath = reader.Value; } catch { currPOSTagger++; numPOSTaggers = 1; posTaggersParams = new POSTaggerParams[1]; posTaggersParams[0] = new POSTaggerParams(); posTaggersParams[0].DNN_POSTaggerConfigurationFileFullPath = reader.Value; } break; case "ClassifierName": clsParams = new ClassifierParams(); clsParams.classifierName = reader.Value; break; case "ClsFinalNetFullPath": clsParams.finalNetFullPath = reader.Value; break; case "ClsConfigurationFileFullPath": clsParams.configurationFileFullPath = reader.Value; break; case "ClsMaxIDInfoFileFullPath": clsParams.maxIDInfoFileFullPath = reader.Value; break; case "TrainInputParsingMode": trainInputParsingMode = reader.Value; break; case "TestInputParsingMode": testInputParsingMode = reader.Value; break; case "LogExamplesEvenNoTargetDetected": logExamplesEvenNoTargetDetected = bool.Parse(reader.Value); break; case "WordOnlyVocabularyScope": wordOnlyVocabularyScope = reader.Value; break; case "TargetType": targetType = reader.Value; break; case "TargetMode": targetMode = reader.Value; break; case "WordOnlyEncoding": wordOnlyEncoding = reader.Value; break; default: Console.WriteLine("Incorrect configuration parameter." + reader.Value + " is invalid bitfieldValue for Configuration Parameter" + reader.Name); break; } // end switch (reader.Name) } // end while (reader.MoveToNextAttribute()) } // end if (reader.HasAttributes) // Get back to root element reader.MoveToElement(); }// end if (reader.NodeType == XmlNodeType.Element) else { Console.WriteLine("Incorrect configuration parameter. Expected: ConfigurationParameter, Found: " + reader.Name); } } }// end of while (reader.Read()) }