C# (CSharp) Class System.Xml. XmlDocument Code Examples

C# (CSharp) System.Xml.XmlDocument - 30 examples found. These are the top rated real world C# (CSharp) examples of class System.Xml.XmlDocument extracted from open source projects. You can rate examples to help us improve the quality of examples
Inheritance: XmlNode
Example #1
0
        private void buttonRegister_Click(object sender, EventArgs e)
        {
            if (this.textBoxForLogin.Text.Any() == false || this.textBoxForName.Text.Any() == false ||
                this.textBoxForSurname.Text.Any() == false || this.textBoxForPassword.Text.Any() == false)
            {
                MessageBox.Show("You didn't fill all fields!", "Error", MessageBoxButtons.OK);
            }
            else
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(Data.teachersLocation);
                XmlNode root = xmlDocument.SelectSingleNode("root");

                var existing = root.SelectSingleNode("teacher[login='" + this.textBoxForLogin.Text + "' and password='"
                    + this.textBoxForPassword.Text.GetHashCode() + "']");

                if (existing != null)
                {
                    MessageBox.Show("This users already exists!", "Error", MessageBoxButtons.OK);
                }
                else
                {
                    var newTeacher = new Teacher(textBoxForName.Text, textBoxForSurname.Text,
                        textBoxForLogin.Text, textBoxForPassword.Text.GetHashCode().ToString());
                    newTeacher.AddNewTeacher();
                    MessageBox.Show("Вы успешно зарегистрировали нового учителя", "Создан", MessageBoxButtons.OK);
                    this.Close();
                }
            }
        }
 public string GetSchema()
 {
     var schema = getMainSchema();
     XmlDocument doc = new XmlDocument();
     doc.Load(schema);
     return doc.OuterXml;
 }
 public static List<Structure> LoadXmlFile(string filename)
 {
     XmlDocument document = new XmlDocument();
     document.Load(filename);
     ProfileReader reader = new ProfileReader();
     return reader.Read(document);
 }
Example #4
0
	internal XmlAttributeCollection (XmlNode parent) : base (parent)
	{
		ownerElement = parent as XmlElement;
		ownerDocument = parent.OwnerDocument;
		if(ownerElement == null)
			throw new XmlException ("invalid construction for XmlAttributeCollection.");
	}
Example #5
0
 public StudyDeleteRecord(
      String _studyInstanceUid_
     ,DateTime _timestamp_
     ,String _serverPartitionAE_
     ,ServerEntityKey _filesystemKey_
     ,String _backupPath_
     ,String _reason_
     ,String _accessionNumber_
     ,String _patientId_
     ,String _patientsName_
     ,String _studyId_
     ,String _studyDescription_
     ,String _studyDate_
     ,String _studyTime_
     ,XmlDocument _archiveInfo_
     ,String _extendedInfo_
     ):base("StudyDeleteRecord")
 {
     StudyInstanceUid = _studyInstanceUid_;
     Timestamp = _timestamp_;
     ServerPartitionAE = _serverPartitionAE_;
     FilesystemKey = _filesystemKey_;
     BackupPath = _backupPath_;
     Reason = _reason_;
     AccessionNumber = _accessionNumber_;
     PatientId = _patientId_;
     PatientsName = _patientsName_;
     StudyId = _studyId_;
     StudyDescription = _studyDescription_;
     StudyDate = _studyDate_;
     StudyTime = _studyTime_;
     ArchiveInfo = _archiveInfo_;
     ExtendedInfo = _extendedInfo_;
 }
Example #6
0
        public GeoIP()
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://freegeoip.net/xml/");
                request.Proxy = null;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                string responseString = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
                response.Close();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(responseString);

                WANIP = doc.SelectSingleNode("Response//Ip").InnerXml.ToString();
                Country = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryName").InnerXml.ToString() : "Unknown";
                CountryCode = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString() : "-";
                Region = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//RegionName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//RegionName").InnerXml.ToString() : "Unknown";
                City = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//City").InnerXml.ToString())) ? doc.SelectSingleNode("Response//City").InnerXml.ToString() : "Unknown";
            }
            catch
            {
                WANIP = "-";
                Country = "Unknown";
                CountryCode = "-";
                Region = "Unknown";
                City = "Unknown";
            }
        }
Example #7
0
        //Appends the any xml file/folder nodes onto the folder
        private void AddXmlNodes(FolderCompareObject folder, int numOfPaths, XmlDocument xmlDoc)
        {
            List<XMLCompareObject> xmlObjList = new List<XMLCompareObject>();
            List<string> xmlFolderList = new List<string>();

            for (int i = 0; i < numOfPaths; i++)
            {
                string path = Path.Combine(folder.GetSmartParentPath(i), folder.Name);

                if (Directory.Exists(path))
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(path);
                    FileInfo[] fileList = dirInfo.GetFiles();
                    DirectoryInfo[] dirInfoList = dirInfo.GetDirectories();
                    string xmlPath = Path.Combine(path, CommonXMLConstants.MetadataPath);

                    if (!File.Exists(xmlPath))
                        continue;

                    CommonMethods.LoadXML(ref xmlDoc, xmlPath);
                    xmlObjList = GetAllFilesInXML(xmlDoc);
                    xmlFolderList = GetAllFoldersInXML(xmlDoc);
                    RemoveSimilarFiles(xmlObjList, fileList);
                    RemoveSimilarFolders(xmlFolderList, dirInfoList);
                }

                AddFileToChild(xmlObjList, folder, i, numOfPaths);
                AddFolderToChild(xmlFolderList, folder, i, numOfPaths);
                xmlObjList.Clear();
                xmlFolderList.Clear();
            }
        }
Example #8
0
 public WMIBMySQL()
 {
     string file = Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + "unwrittensql.xml";
     Core.RecoverFile(file);
     if (File.Exists(file))
     {
         Syslog.WarningLog("There is a mysql dump file from previous run containing mysql rows that were never successfuly inserted, trying to recover them");
         XmlDocument document = new XmlDocument();
         using (TextReader sr = new StreamReader(file))
         {
             document.Load(sr);
             using (XmlNodeReader reader = new XmlNodeReader(document.DocumentElement))
             {
                 XmlSerializer xs = new XmlSerializer(typeof(Unwritten));
                 Unwritten un = (Unwritten)xs.Deserialize(reader);
                 lock (unwritten.PendingRows)
                 {
                     unwritten.PendingRows.AddRange(un.PendingRows);
                 }
             }
         }
     }
     Thread reco = new Thread(Exec) {Name = "MySQL/Recovery"};
     Core.ThreadManager.RegisterThread(reco);
     reco.Start();
 }
Example #9
0
 private void saveXml()
 {
     string error = String.Empty;
     XmlDocument modifiedXml = new XmlDocument();
     modifiedXml.LoadXml(txtXml.Text);
     pageNode.SetPersonalizationFromXml(HttpContext.Current, modifiedXml, out error);
 }
Example #10
0
        public void Save(string path)
        {
            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement("Resources");
            doc.AppendChild(root);

            XmlElement sheetsElem = doc.CreateElement("SpriteSheets");
            foreach (KeyValuePair<string, SpriteSheet> pair in SpriteSheets)
            {
                XmlElement elem = doc.CreateElement(pair.Key);
                pair.Value.Save(doc, elem);
                sheetsElem.AppendChild(elem);
            }
            root.AppendChild(sheetsElem);

            XmlElement spritesElem = doc.CreateElement("Sprites");
            foreach (KeyValuePair<string, Sprite> pair in Sprites)
            {
                XmlElement elem = doc.CreateElement(pair.Key);
                pair.Value.Save(doc, elem);
                spritesElem.AppendChild(elem);
            }
            root.AppendChild(spritesElem);

            XmlElement animsElem = doc.CreateElement("Animations");
            foreach (KeyValuePair<string, Animation> pair in Animations)
            {
                XmlElement elem = doc.CreateElement(pair.Key);
                pair.Value.Save(doc, elem);
                animsElem.AppendChild(elem);
            }
            root.AppendChild(animsElem);

            doc.Save(path);
        }
Example #11
0
	private void Page_Load(object sender, EventArgs e)
	{
		XmlDocument configDoc = new XmlDocument();
		configDoc.Load(Server.MapPath(Configuration.ConfigFile));
		Configuration configuration = new Configuration(configDoc);
		treeNavigator.ContentFile = configuration.ExamplesDataFile;
	}
	/// <summary>
	/// Load the style from assmebly resource.
	/// </summary>
	public virtual void New()
	{
		Assembly ass		= Assembly.GetExecutingAssembly();
		Stream str			= ass.GetManifestResourceStream("AODL.Resources.OD.manifest.xml");
		this.Manifest		= new XmlDocument();
		this.Manifest.Load(str);
	}
        /// <summary>
        /// 设置流程文件缓存
        /// </summary>
        /// <param name="processGUID"></param>
        /// <param name="xmlDoc"></param>
        /// <returns></returns>
        internal static XmlDocument SetXpdlCache(string processGUID, string version, XmlDocument xmlDoc)
        {
            var str = processGUID + version;
            var strMD5 = MD5Helper.GetMD5(str);

            return _xpdlCache.GetOrAdd(strMD5, xmlDoc);
        }
Example #14
0
 public override object[] CreateMapping(params object[] initParams)
 {
     XmlDocument document = (XmlDocument) initParams[0];
     string str = (string) initParams[1];
     DataSet mappingSet = this.GetMappingSet();
     XmlDocument indexesDoc = new XmlDocument();
     indexesDoc.Load(Path.Combine(str, "indexes.xml"));
     foreach (XmlNode node in document.DocumentElement.SelectNodes("//type"))
     {
         DataRow row = mappingSet.Tables["types"].NewRow();
         int mappedTypeId = int.Parse(node.Attributes["mappedTypeId"].Value);
         int num2 = int.Parse(node.Attributes["selectedTypeId"].Value);
         row["MappedTypeId"] = mappedTypeId;
         row["SelectedTypeId"] = num2;
         if (num2 == 0)
         {
             XmlNode node2 = indexesDoc.SelectSingleNode("//type[typeId[text()='" + mappedTypeId + "']]");
             row["TypeName"] = node2.SelectSingleNode("typeName").InnerText;
             row["Remark"] = node2.SelectSingleNode("remark").InnerText;
         }
         mappingSet.Tables["types"].Rows.Add(row);
         XmlNodeList attributeNodeList = node.SelectNodes("attributes/attribute");
         this.MappingAttributes(mappedTypeId, mappingSet, attributeNodeList, indexesDoc, str);
     }
     mappingSet.AcceptChanges();
     return new object[] { mappingSet };
 }
Example #15
0
        public void ConfigurationMessagesTest()
        {
            try {
                LogLog.EmitInternalMessages = false;
                LogLog.InternalDebugging = true;

                XmlDocument log4netConfig = new XmlDocument();
                log4netConfig.LoadXml(@"
                <log4net>
                  <appender name=""LogLogAppender"" type=""log4net.Tests.LoggerRepository.LogLogAppender, log4net.Tests"">
                    <layout type=""log4net.Layout.SimpleLayout"" />
                  </appender>
                  <appender name=""MemoryAppender"" type=""log4net.Appender.MemoryAppender"">
                    <layout type=""log4net.Layout.SimpleLayout"" />
                  </appender>
                  <root>
                    <level value=""ALL"" />
                    <appender-ref ref=""LogLogAppender"" />
                    <appender-ref ref=""MemoryAppender"" />
                  </root>  
                </log4net>");

                ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
                rep.ConfigurationChanged += new LoggerRepositoryConfigurationChangedEventHandler(rep_ConfigurationChanged);

                ICollection configurationMessages = XmlConfigurator.Configure(rep, log4netConfig["log4net"]);

                Assert.IsTrue(configurationMessages.Count > 0);
            }
            finally {
                LogLog.EmitInternalMessages = true;
                LogLog.InternalDebugging = false;
            }
        }
        /// <summary>
        /// Changes the name of an analyzer setting property, if it exists.
        /// </summary>
        /// <param name="document">
        /// The settings document.
        /// </param>
        /// <param name="analyzerName">
        /// The analyzer name.
        /// </param>
        /// <param name="legacyPropertyName">
        /// The legacy name of the property.
        /// </param>
        /// <param name="newPropertyName">
        /// The new name of the property.
        /// </param>
        public static void ChangeAnalyzerSettingName(XmlDocument document, string analyzerName, string legacyPropertyName, string newPropertyName)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertValidString(analyzerName, "analyzerName");
            Param.AssertValidString(legacyPropertyName, "legacyPropertyName");
            Param.AssertValidString(newPropertyName, "newPropertyName");

            XmlNode analyzersNode = document.DocumentElement.SelectSingleNode("Analyzers");
            if (analyzersNode != null)
            {
                XmlNode analyzerNode = analyzersNode.SelectSingleNode("Analyzer[@AnalyzerId=\"" + analyzerName + "\"]");

                if (analyzerNode != null)
                {
                    XmlNode analyzerSettingsNode = analyzerNode.SelectSingleNode("AnalyzerSettings");
                    if (analyzerSettingsNode != null)
                    {
                        // This rule node must be moved under the new analyzer section.
                        // Check whether this section already exists.
                        XmlNode propertyNode = analyzerSettingsNode.SelectSingleNode("*[@Name=\"" + legacyPropertyName + "\"]");

                        if (propertyNode != null)
                        {
                            XmlAttribute attribute = propertyNode.Attributes["Name"];
                            if (attribute != null)
                            {
                                attribute.Value = newPropertyName;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// loads a xml from the web server
        /// </summary>
        /// <param name="_url">URL of the XML file</param>
        /// <returns>A XmlDocument object of the XML file</returns>
        public static XmlDocument LoadXml(string _url)
        {
            var xmlDoc = new XmlDocument();
            
            try
            {
                while (Helper.pingForum("forum.mods.de", 10000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                xmlDoc.Load(_url);
            }
            catch (XmlException)
            {
                while (Helper.pingForum("forum.mods.de", 100000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                WebClient client = new WebClient(); ;
                Stream stream = client.OpenRead(_url);
                StreamReader reader = new StreamReader(stream);
                string content = reader.ReadToEnd();

                content = RemoveTroublesomeCharacters(content);
                xmlDoc.LoadXml(content);
            }

            return xmlDoc;
        }
        public override bool InitOne(ContentManager content, int id)
        {
            XmlDocument _doc = new XmlDocument();
            _doc.Load(_xmlInfo);
            XmlNode _gameTitle = _doc.SelectSingleNode(@"//GameTitle[@id = '" + id.ToString() + "']");

            _prototype[id] = new GameTitle();
            XmlNodeList _listOfTitle = _gameTitle.SelectNodes(@"//Title");
            _prototype[id]._nsprite = _listOfTitle.Count;
            _prototype[id]._sprite = new GameSprite[_prototype[id]._nsprite];

            for (int i = 0; i < _prototype[id]._nsprite; i++)
            {
                int _numofframe = int.Parse(_listOfTitle[i].SelectSingleNode(@"NumOfFrames").InnerText);
                string _contentname = _listOfTitle[i].SelectSingleNode(@"ContentName").InnerText;

                Texture2D[] _textures = new Texture2D[_numofframe];

                for (int j = 0; j < _numofframe; ++j)
                {
                    _textures[j] = content.Load<Texture2D>(_contentname + j.ToString("00"));
                }
                _prototype[id]._sprite[i] = new GameSprite(_textures, 0, 0);
            }

            _prototype[id].X = float.Parse(_gameTitle.SelectSingleNode(@"X").InnerText);
            _prototype[id].Y = float.Parse(_gameTitle.SelectSingleNode(@"Y").InnerText);
            ((GameTitle)_prototype[id]).DelayTime = int.Parse((_gameTitle.SelectSingleNode(@"DelayTime").InnerText));
            return true;
        }
Example #19
0
        public AvatarAnimations()
        {
            using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(reader);
                foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
                {
                    if (nod.Attributes["name"] != null)
                    {
                        string name = nod.Attributes["name"].Value;
                        UUID id = (UUID) nod.InnerText;
                        string animState = nod.Attributes["state"].Value;

                        try
                        {
                            AnimsUUID.Add(name, id);
                            if (animState != "" && !AnimStateNames.ContainsKey(id))
                                AnimStateNames.Add(id, animState);
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
 private static void ProcessSearchQueries(XmlTextWriter writer)
 {
     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.Load("..\\..\\performance-test.xml");
     foreach (XmlNode query in xmlDoc.SelectNodes("review-queries/query"))
     {
         SaveQueryToLog(query.OuterXml);
         var type = query.Attributes.GetNamedItem("type");
         switch (type.Value)
         {
             case "by-period":
                 // Start date and end date are mandatory.
                 DateTime startDate = DateTime.Parse(query.GetChildText("start-date"));
                 DateTime endDate = DateTime.Parse(query.GetChildText("end-date"));
                 var reviewsByPeriod = BookstoreDAL.FindReviewsByPeriod(startDate, endDate);
                 WriteReviews(writer, reviewsByPeriod);
                 break;
             case "by-author":
                 string authorName = query.GetChildText("author-name");
                 var reviewsByAuthor = BookstoreDAL.FindReviewsByAuthor(authorName);
                 WriteReviews(writer, reviewsByAuthor);
                 break;
             default:
                 throw new ArgumentException("Type not supported!");
         }
     }
 }
Example #21
0
        /// <summary>
        /// Define o valor de uma configuração
        /// </summary>
        /// <param name="file">Caminho do arquivo (ex: c:\program.exe.config)</param>
        /// <param name="key">Nome da configuração</param>
        /// <param name="value">Valor a ser salvo</param>
        /// <returns></returns>
        public static bool SetValue(string file, string key, string value)
        {
            var fileDocument = new XmlDocument();
            fileDocument.Load(file);
            var nodes = fileDocument.GetElementsByTagName(AddElementName);

            if (nodes.Count == 0)
            {
                return false;
            }

            for (var i = 0; i < nodes.Count; i++)
            {
                var node = nodes.Item(i);
                if (node == null || node.Attributes == null || node.Attributes.GetNamedItem(KeyPropertyName) == null)
                    continue;
                
                if (node.Attributes.GetNamedItem(KeyPropertyName).Value == key)
                {
                    node.Attributes.GetNamedItem(ValuePropertyName).Value = value;
                }
            }

            var writer = new XmlTextWriter(file, null) { Formatting = Formatting.Indented };
            fileDocument.WriteTo(writer);
            writer.Flush();
            writer.Close();
            return true;
        }
Example #22
0
        private bool OverWriting() {
        //private async Task<bool> OverWriting() {
            if (ListingQueue.Any()) {
                XmlDocument xmlDoc;
                XmlElement xmlEle;
                XmlNode newNode;

                xmlDoc = new XmlDocument();
                xmlDoc.Load("ImageData.xml"); // XML문서 로딩

                newNode = xmlDoc.SelectSingleNode("Images"); // 추가할 부모 Node 찾기
                xmlEle = xmlDoc.CreateElement("Image");
                newNode.AppendChild(xmlEle);
                newNode = newNode.LastChild;
                xmlEle = xmlDoc.CreateElement("ImagePath"); // 추가할 Node 생성
                xmlEle.InnerText = ListingQueue.Peek();
                ListingQueue.Dequeue();
                newNode.AppendChild(xmlEle); // 위에서 찾은 부모 Node에 자식 노드로 추가..

                xmlDoc.Save("ImageData.xml"); // XML문서 저장..
                xmlDoc = null;

                return true;
            }
            return false;
        }
Example #23
0
        private void DlgTips_Load(object sender, EventArgs e)
        {   
            try
            {
                string strxml = "";
                using (StreamReader streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Johnny.Kaixin.WinUI.Resources.Versions.config")))
                {
                    strxml = streamReader.ReadToEnd();
                }

                XmlDocument objXmlDoc = new XmlDocument();
                objXmlDoc.LoadXml(strxml);

                if (objXmlDoc == null)
                    return;

                DataView dv = GetData(objXmlDoc, "ZrAssistant/Versions");

                for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                {
                    _versionList.Add(dv.Table.Rows[ix][0].ToString(), dv.Table.Rows[ix][1].ToString());
                    cmbVersion.Items.Add(dv.Table.Rows[ix][0].ToString());
                }

                chkNeverDisplay.Checked = Properties.Settings.Default.NeverDisplay;
                cmbVersion.SelectedIndex = 0;
                SetTextValue();
                btnOk.Select();
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("DlgTips", ex);
            }
        }
        void addConfigFile(string configFilename)
        {
            var dirName = Utils.getDirName(Utils.getFullPath(configFilename));
            addAssemblySearchPath(dirName);

            try {
                using (var xmlStream = new FileStream(configFilename, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                    var doc = new XmlDocument();
                    doc.Load(XmlReader.Create(xmlStream));
                    foreach (var tmp in doc.GetElementsByTagName("probing")) {
                        var probingElem = tmp as XmlElement;
                        if (probingElem == null)
                            continue;
                        var privatePath = probingElem.GetAttribute("privatePath");
                        if (string.IsNullOrEmpty(privatePath))
                            continue;
                        foreach (var path in privatePath.Split(';'))
                            addAssemblySearchPath(Path.Combine(dirName, path));
                    }
                }
            }
            catch (IOException) {
            }
            catch (XmlException) {
            }
        }
		public void SetUp()
		{
			TestHelper.SetupLog4NetForTests();
			Umbraco.Core.Configuration.UmbracoSettings.UseLegacyXmlSchema = false;
			_httpContextFactory = new FakeHttpContextFactory("~/Home");
			//ensure the StateHelper is using our custom context
			StateHelper.HttpContext = _httpContextFactory.HttpContext;
			
			_umbracoContext = new UmbracoContext(_httpContextFactory.HttpContext, 
				new ApplicationContext(), 
				new DefaultRoutesCache(false));

			_umbracoContext.GetXmlDelegate = () =>
				{
					var xDoc = new XmlDocument();

					//create a custom xml structure to return

					xDoc.LoadXml(GetXml());
					//return the custom x doc
					return xDoc;
				};

			_publishedContentStore = new DefaultPublishedContentStore();			
		}
Example #26
0
File: Test.cs Project: hcesar/Chess
        internal static IList<Test> LoadAll()
        {
            var file = new FileInfo("tests.xml");

            if (!file.Exists)
                return new Test[0];

            XmlDocument xml = new XmlDocument();
            using (var fs = file.OpenRead())
                xml.Load(fs);

            var ret = new List<Test>();
            foreach (XmlNode node in xml.SelectNodes("/Tests/*"))
            {
                var n = node.SelectSingleNode("./Type");

                if (n == null)
                    throw new InvalidOperationException("Test Type must be informed.");

                var typeName = n.InnerText;
                var type = FindType(typeName);

                if (type == null)
                    throw new InvalidOperationException(string.Format("'{0}' is not a valid Test.", typeName));

                var obj = (Test)Activator.CreateInstance(type);
                node.ToEntity(obj);

                ret.Add(obj);
            }

            return ret;
        }
Example #27
0
        public static string UpdateSagaXMLFile(ref DataTable _XMLDt, string XMLpath)
        {
            try
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(XMLpath);

                XmlNode xmlnode = xmldoc.DocumentElement.ChildNodes[0];
                xmlnode["ODBCDriverName"].InnerText = _XMLDt.Rows[0]["ODBCDriverName"].ToString();
                xmlnode["HostName"].InnerText = _XMLDt.Rows[0]["HostName"].ToString();
                xmlnode["ServerName"].InnerText = _XMLDt.Rows[0]["ServerName"].ToString();
                xmlnode["ServiceName"].InnerText = _XMLDt.Rows[0]["ServiceName"].ToString();
                xmlnode["Protocol"].InnerText = _XMLDt.Rows[0]["Protocol"].ToString();
                xmlnode["DatabaseName"].InnerText = _XMLDt.Rows[0]["DatabaseName"].ToString();
                xmlnode["UserId"].InnerText = _XMLDt.Rows[0]["UserId"].ToString();
                xmlnode["Password"].InnerText = _XMLDt.Rows[0]["Password"].ToString();
                xmlnode["ClientLocale"].InnerText = _XMLDt.Rows[0]["ClientLocale"].ToString();
                xmlnode["DatabaseLocale"].InnerText = _XMLDt.Rows[0]["DatabaseLocale"].ToString();

                xmldoc.Save(XMLpath);

                return "";
            }
            catch (Exception err)
            {
                return err.Message;
            }
        }
        public string GetXml()
        {
            // <?xml version="1.0" encoding="UTF-8" ?>
            // <gateways ua="Example 1.0">
            //     <merchant>
            //         <account>10011001</account>
            //         <site_id>1234</site_id>
            //         <site_secure_code>123456</site_secure_code>
            //     </merchant>
            //     <customer>
            //         <country>NL</country>
            //     </customer>
            // </gateways>

            var xmlDoc = new XmlDocument();
            var gatewaysNode = (XmlElement) xmlDoc.AppendChild(xmlDoc.CreateElement("gateways"));
            gatewaysNode.SetAttribute("ua", "Example 1.0");

            var merchantNode = (XmlElement) gatewaysNode.AppendChild(xmlDoc.CreateElement("merchant"));
            merchantNode.AppendChild(xmlDoc.CreateElement("account")).InnerText = AccountId.ToString();
            merchantNode.AppendChild(xmlDoc.CreateElement("site_id")).InnerText = SiteId.ToString();
            merchantNode.AppendChild(xmlDoc.CreateElement("site_secure_code")).InnerText = SiteSecureId.ToString();

            var customerNode = (XmlElement) gatewaysNode.AppendChild(xmlDoc.CreateElement("customer"));
            customerNode.AppendChild(xmlDoc.CreateElement("country")).InnerText = Country;

            return xmlDoc.OuterXml;
        }
Example #29
0
        public override string ToText(Subtitle subtitle, string title)
        {
            string xmlStructure =
                "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine +
                "<EEG708Captions/>";

            XmlDocument xml = new XmlDocument();
            xml.LoadXml(xmlStructure);

            foreach (Paragraph p in subtitle.Paragraphs)
            {
                XmlNode paragraph = xml.CreateElement("Caption");
                XmlAttribute start = xml.CreateAttribute("timecode");
                start.InnerText = EncodeTimeCode(p.StartTime);
                paragraph.Attributes.Append(start);
                XmlNode text = xml.CreateElement("Text");
                text.InnerText = p.Text;
                paragraph.AppendChild(text);
                xml.DocumentElement.AppendChild(paragraph);

                paragraph = xml.CreateElement("Caption");
                start = xml.CreateAttribute("timecode");
                start.InnerText = EncodeTimeCode(p.EndTime);
                paragraph.Attributes.Append(start);
                xml.DocumentElement.AppendChild(paragraph);
            }

            return ToUtf8XmlString(xml);
        }
        private static XmlElement GetRootNodeXmlDocument(string path)
        {
            var doc = new XmlDocument();
            doc.Load(path);

            return doc.DocumentElement;
        }