//Method to take a signed URL and return information contained in the get response public static string Fetch(string url) { string asin = ""; try { //Makes a request, and exports the response into an XML file WebRequest request = HttpWebRequest.Create(url); WebResponse response = request.GetResponse(); XmlDocument doc = new XmlDocument(); doc.Load(response.GetResponseStream()); //Parse XML document for errors XmlNodeList errorMessageNodes = doc.GetElementsByTagName("Message", NAMESPACE); if (errorMessageNodes != null && errorMessageNodes.Count > 0) { String message = errorMessageNodes.Item(0).InnerText; string error; MessageBox.Show("Unfortunately, music preview isn't available for this track."); //MessageBox.Show("Error: " + message + " (but signature worked)"); return null; } XmlNode asinNode = doc.GetElementsByTagName("ASIN", NAMESPACE).Item(0); if (asinNode != null) asin = asinNode.InnerText; return asin; } catch (Exception e) { System.Console.WriteLine("Caught Exception: " + e.Message); System.Console.WriteLine("Stack Trace: " + e.StackTrace); } return null; }
public void getWeather() { XmlDocument docX = new XmlDocument(); try { docX.Load("http://www.kma.go.kr/wid/queryDFS.jsp?gridx=98&gridy=84"); } catch { return; } XmlNodeList hourList = docX.GetElementsByTagName("hour"); XmlNodeList tempList = docX.GetElementsByTagName("temp"); XmlNodeList weatherList = docX.GetElementsByTagName("wfKor"); weather = " = 울산 날씨 =\n"; weather += hourList[0].InnerText + "시 : " + weatherList[0].InnerText + " (" + tempList[0].InnerText + "℃)\n"; weather += hourList[1].InnerText + "시 : " + weatherList[1].InnerText + " (" + tempList[1].InnerText + "℃)\n"; weather += hourList[2].InnerText + "시 : " + weatherList[2].InnerText + " (" + tempList[2].InnerText + "℃)\n"; weather += hourList[3].InnerText + "시 : " + weatherList[3].InnerText + " (" + tempList[3].InnerText + "℃)\n"; // weather += hourList[4].InnerText + "시 : " + weatherList[4].InnerText + "(" + tempList[4].InnerText + "℃)\n"; // weather += hourList[5].InnerText + "시 : " + weatherList[5].InnerText + "(" + tempList[5].InnerText + "℃)\n"; }
/* List<Edit> edits; //everything is stored by edits public List<Edit> Edits { get { return edits; } set { edits = value; } } */ //Records when an edit has occured and what the edit was //The above structures contain the most updated version of the synthesis /* <localid>rc1</localid> <name>benzaldehyde</name> <refid>aldehyde</refid> <molweight>106.12</molweight> <state>solid</state> <density temp="20">null</density> <islimiting>true</islimiting> <mols unit="mmol">57</mols> <mass unit="g">6</mass> <volume>null</volume> * */ public static Synthesis ReadFile(string filename) { XmlDocument doc = new XmlDocument(); doc.Load(filename); XmlNode header = doc.GetElementById("header"); XmlNodeList editHeader = doc.GetElementsByTagName("editheader"); XmlNodeList reactantNodeList = doc.GetElementsByTagName("reactant"); XmlNodeList reagentNodeList = doc.GetElementsByTagName("reagent"); XmlNodeList productNodeList = doc.GetElementsByTagName("product"); ObservableCollection<Compound> reactants = ReadBlock(reactantNodeList, COMPOUND_TYPES.Reactant); ObservableCollection<Compound> reagents = ReadBlock(reagentNodeList, COMPOUND_TYPES.Reagent); ObservableCollection<Compound> products = ReadBlock(productNodeList, COMPOUND_TYPES.Product); string synthName = GetSynthesisName(editHeader); int projectID = GetSynthesisProjectID(editHeader); SynthesisInfo previousStep = GetPreviousStep(editHeader); SynthesisInfo nextStep = GetNextStep(editHeader); string procedureText = GetProcedureText(editHeader); Synthesis synth = new Synthesis(reactants, reagents, products, synthName, projectID, previousStep, nextStep, procedureText); ReadMolData(doc, synth.AllCompounds); return synth; }
//--// static public Document Load(string file, Document doc) { Document docRet = null; Console.WriteLine("Processing file: " + file); System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlDoc.NameTable); nsMgr.AddNamespace("ScatterNSOld", "http://tempuri.org/ScatterfileSchema.xsd"); nsMgr.AddNamespace("ScatterNS", "http://schemas.microsoft.com/netmf/ScatterfileSchema.xsd"); xmlDoc.Load(file); try { docRet = new Document(xmlDoc.GetElementsByTagName("ScatterFile", "ScatterNS").Item(0), doc); } catch {} try { docRet = new Document(xmlDoc.GetElementsByTagName("ScatterFile", "ScatterNSOld").Item(0), doc); } catch {} if (docRet == null) { docRet = new Document(xmlDoc.GetElementsByTagName("ScatterFile").Item(0), doc); } return(docRet); }
private static void RemoveSoundNodes(string ovfFile) { var xdoc = new XmlDocument(); xdoc.Load(ovfFile); //<rasd:ElementName><Item><VirtualHardwareSection> <VirtualSystem ovf:id="Centos65_x64_OpenERP"> <Envelope var parentNode = xdoc.GetElementsByTagName("VirtualHardwareSection").Item(0); var node = xdoc.GetElementsByTagName("Item"); // xdoc.SelectNodes("/Envelope/VirtualSystem/VirtualHardwareSection/Item/rasd:ElementName"); var needDelList = new List<XmlElement>(); foreach (XmlElement n in node) { var childs = n.GetElementsByTagName("rasd:ElementName"); if (childs.Count > 0) { if (childs[0].InnerText.Trim().ToUpper() == "sound".ToUpper()) { needDelList.Add(n); } } } foreach (var element in needDelList) { parentNode.RemoveChild(element); } xdoc.Save(ovfFile); }
private void Auth() { string mpopdata = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><AutoLogin ProjectId=\"11321\" SubProjectId=\"0\" ShardId=\"0\" Mpop=\""+tokenmpop+"\"/>"; HttpWebRequest myWebRequest2 = (HttpWebRequest)WebRequest.Create(@"https://authdl.mail.ru/sz.php?hint=AutoLogin"); myWebRequest2.ContentType = "application/x-www-form-urlencoded"; myWebRequest2.Method = "POST"; myWebRequest2.UserAgent = "Downloader/11450"; // myWebRequest2.CookieContainer = myCookie; byte[] mpoppostbyte = Encoding.UTF8.GetBytes(mpopdata); Stream MyRequest2 = myWebRequest2.GetRequestStream(); MyRequest2.Write(mpoppostbyte, 0, mpoppostbyte.Length); MyRequest2.Close(); HttpWebResponse myResponse2 = (HttpWebResponse)myWebRequest2.GetResponse(); Stream myStream = myResponse2.GetResponseStream(); StreamReader sr = new StreamReader(myStream); String myRespString = sr.ReadToEnd(); myResponse2.Close(); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(myRespString); string myAPersId = xmldoc.GetElementsByTagName("AutoLogin").Item(0).Attributes["PersId"].Value; string myAKey = xmldoc.GetElementsByTagName("AutoLogin").Item(0).Attributes["Key"].Value; Environment.SetEnvironmentVariable("GC_PROJECT_ID", "11321"); Environment.SetEnvironmentVariable("GC_TYPE_ID", "0"); lStat.Text = "Запуск игры"; Application.DoEvents(); System.Threading.Thread.Sleep(5000); Process Armata = Process.Start("ArmoredWarfare.exe", " --sz_pers_id=" + myAPersId + " --sz_token=" + myAKey); System.Threading.Thread.Sleep(5000); lStat.Text = "Играем"; Armata.EnableRaisingEvents = true; Armata.Exited += new EventHandler(Armata_Exited); }
private void PopulaGridInutilizados() { try { DirectoryInfo diretorio = new DirectoryInfo(sPastaProtocolos); FileSystemInfo[] itens = diretorio.GetFileSystemInfos("*.xml"); int irow = 0; dgvInutilizacoes.Rows.Clear(); foreach (FileSystemInfo item in itens) { if ((item.Name.Contains("_inu")) && (!item.Name.Contains("_ped_inu"))) { XmlDocument xml = new XmlDocument(); xml.Load(item.FullName); dgvInutilizacoes.Rows.Add(); dgvInutilizacoes[0, irow].Value = (xml.GetElementsByTagName("tpAmb").Item(0).InnerText == "2" ? "Homologação" : "Produção"); dgvInutilizacoes[1, irow].Value = xml.GetElementsByTagName("nNFIni").Item(0).InnerText.PadLeft(9, '0'); dgvInutilizacoes[2, irow].Value = xml.GetElementsByTagName("nNFFin").Item(0).InnerText.PadLeft(9, '0'); dgvInutilizacoes[3, irow].Value = Convert.ToDateTime(xml.GetElementsByTagName("dhRecbto").Item(0).InnerText).ToString("dd/MM/yyyy"); dgvInutilizacoes[4, irow].Value = xml.GetElementsByTagName("nProt").Item(0).InnerText; irow++; } } } catch (Exception ex) { throw ex; } }
public void wczytajUstawienia() { if(_ustawieniaWczytane) return; _ustawieniaWczytane = true; XmlDocument plikXML = new XmlDocument(); plikXML.Load(@"C:\museSort\config.xml"); var xmlNode = plikXML.GetElementsByTagName("folderGlowny").Item(0); if (xmlNode != null) folderGlowny = xmlNode.InnerText; xmlNode = plikXML.GetElementsByTagName("domyslneSortowanieMuzyki").Item(0); if (xmlNode != null) domyslneSortowanieMuzyki = xmlNode.InnerText; xmlNode = plikXML.GetElementsByTagName("domyslneSortowanieFilmow").Item(0); if (xmlNode != null && xmlNode.InnerText!="") domyslneSortowanieFilmow = xmlNode.InnerText; foreach (XmlNode x in plikXML.GetElementsByTagName("rozszerzenieAudio")) { wspieraneRozszerzeniaAudio.Add(x.InnerText); } foreach (XmlNode x in plikXML.GetElementsByTagName("rozszerzenieVideo")) { wspieraneRozszerzeniaVideo.Add(x.InnerText); } Film.wczytajWzorceZPliku(@"C:\museSort\config.xml"); Utwor.wczytajWzorceZPliku(@"C:\museSort\config.xml"); }
public void TestTestListGeneratorTestListNodeTwoNodesGenerated() { System.Xml.XmlDocument doc = GenerateTestListXmlDocument(); XmlNode testListNode = doc.GetElementsByTagName("TestList").Item(0); Assert.AreEqual <int>(2, doc.GetElementsByTagName("TestList").Count); }
public Level(ref StreamReader s, XmlDocument xml) { paused = false; ticker = 80; var xlevelnum = xml.GetElementsByTagName("LevelNum"); int xmlLvl = Convert.ToInt32(xlevelnum.Item(0).Value); XmlNodeList roomXMLs = xml.GetElementsByTagName("Room"); Room room1 = new Room(roomXMLs.Item(0)); if ((line = s.ReadLine()) != null) levelNum = Convert.ToInt32(line); rooms = new Room[cellNum, cellNum]; roomMap = new roomState[cellNum, cellNum]; int numRooms = Convert.ToInt32(s.ReadLine()); initialRoom = new Vector2(Convert.ToInt64(s.ReadLine()), Convert.ToInt64(s.ReadLine())); for (int i = 0; i < cellNum; i++) { for (int j = 0; j < cellNum; j++) rooms[i, j] = null; } while(numRooms > 0){ int x = Convert.ToInt32(s.ReadLine()); int y = Convert.ToInt32(s.ReadLine()); rooms[x, y] = new Room(ref s, x, y); roomMap[x, y] = roomState.notVisited; numRooms--; } }
private static string FetchTitle(string url) { try { WebRequest request = HttpWebRequest.Create(url); WebResponse response = request.GetResponse(); XmlDocument doc = new XmlDocument(); doc.Load(response.GetResponseStream()); XmlNodeList errorMessageNodes = doc.GetElementsByTagName("Message", NAMESPACE); if (errorMessageNodes != null && errorMessageNodes.Count > 0) { String message = errorMessageNodes.Item(0).InnerText; return "Error: " + message + " (but signature worked)"; } XmlNode titleNode = doc.GetElementsByTagName("Title", NAMESPACE).Item(0); string title = titleNode.InnerText; return title; } catch (Exception e) { System.Console.WriteLine("Caught Exception: " + e.Message); System.Console.WriteLine("Stack Trace: " + e.StackTrace); } return null; }
public void CheckMarkerPaths(string fileName) { DirectoryInfo markerDir = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(fileName), "Markers")); XmlDocument doc = new XmlDocument(); doc.Load(fileName); if (doc.GetElementsByTagName("markers").Count == 0) return; XmlNodeList markerList = doc.GetElementsByTagName("marker"); if (markerList.Count > 0) { foreach (XmlNode node in markerList) { if(node.Attributes == null || node.Attributes["id"] == null) throw new UserMessageException("Marker id doesn't exist for 'Marker' element in file {1}", fileName); if (node.Attributes == null || node.Attributes["name"] == null) throw new UserMessageException("Marker name doesn't exist for 'Marker' element in file {1}", fileName); string id = node.Attributes["id"].Value; string name = node.Attributes["name"].Value; FileInfo[] f = markerDir.GetFiles(string.Format("{0}.*", id), SearchOption.TopDirectoryOnly); if (f.Length == 0) { throw new UserMessageException("Marker image not found with id {0} and name {1} in file {2}", id, name, fileName); } } } doc.RemoveAll(); doc = null; }
public void TestTestListGeneratorRunConfigurationOnlyOneNodeGenerated() { System.Xml.XmlDocument doc = GenerateTestListXmlDocument(); XmlNode testListNode = doc.GetElementsByTagName("RunConfiguration").Item(0); Assert.AreEqual <int>(1, doc.GetElementsByTagName("RunConfiguration").Count); }
private void LoadXML() { XmlDocument xml = new XmlDocument(); try { xml.Load(path); string Temp = xml.GetElementsByTagName("t")[0].InnerText; string Cloud = xml.GetElementsByTagName("cloud")[0].InnerText; string H = xml.GetElementsByTagName("h")[0].InnerText; string Wind = xml.GetElementsByTagName("w")[0].InnerText; string Pressure = xml.GetElementsByTagName("p")[0].InnerText; tempLabel.Text = "Температура: " + Temp + "°C"; wetLabel.Text = "Влажность: " + H + "%"; windySpeedLabel.Text = "Скорость ветра: " + Wind + "м/с"; pressureLabel.Text = "Давление: " + Pressure + "мм"; cloudyLabel.Text = "Облачность: " + Cloud + "%"; } catch (WebException exception) { tempLabel.Text = "N/A"; cloudyLabel.Text = "N/A"; wetLabel.Text = "N/A"; windySpeedLabel.Text = "N/A"; pressureLabel.Text = "N/A"; MessageBox.Show(exception.Message); } }
protected void Page_Load(object sender, System.EventArgs e) { this.btnOK.Click += new System.EventHandler(this.btnOK_Click); if (!base.IsPostBack) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); this.radEnableAppShengPay.SelectedValue = masterSettings.EnableAppShengPay; PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode("Ecdev.Plugins.Payment.ShengPayMobile.ShengPayMobileRequest"); if (paymentMode != null) { string xml = HiCryptographer.Decrypt(paymentMode.Settings); System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); xmlDocument.LoadXml(xml); try { this.txtPartner.Text = xmlDocument.GetElementsByTagName("SenderId")[0].InnerText; this.txtKey.Text = xmlDocument.GetElementsByTagName("SellerKey")[0].InnerText; } catch { this.txtPartner.Text = ""; this.txtKey.Text = ""; } } PaymentModeInfo paymentMode2 = SalesHelper.GetPaymentMode("Ecdev.Plugins.Payment.ShengPayMobile.ShengPayMobileRequest"); if (paymentMode2 != null) { string xml2 = HiCryptographer.Decrypt(paymentMode2.Settings); System.Xml.XmlDocument xmlDocument2 = new System.Xml.XmlDocument(); xmlDocument2.LoadXml(xml2); } } }
public void TestCompFilter() { var uut = new CompFilter(ResourceType.VEVENT); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(AddNamespace(uut.ToXml())); Assert.AreEqual(1, xmlDoc.GetElementsByTagName("C:comp-filter").Count); var element = xmlDoc.GetElementsByTagName("C:comp-filter")[0]; Assert.AreEqual(ResourceType.VEVENT.ToString(), element.Attributes["name"].Value); Assert.AreEqual(0, element.ChildNodes.Count); uut.AddChild(new TimeRangeFilter() { Start = new DateTime(2000, 1, 1, 21, 0, 0) }); xmlDoc.LoadXml(AddNamespace(uut.ToXml())); element = xmlDoc.GetElementsByTagName("C:comp-filter")[0]; Assert.AreEqual(1, element.ChildNodes.Count); try { uut.AddChild(new TimeRangeFilter()); Assert.Fail(); } catch (InvalidFilterException) { } uut = new CompFilter(ResourceType.VCALENDAR); uut.AddChild(new IsNotDefinedFilter()); try { uut.AddChild(new CompFilter(ResourceType.VEVENT)); Assert.Fail(); } catch (InvalidFilterException) { } }
protected void Page_Load(object sender, System.EventArgs e) { if (!this.Page.IsPostBack) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); this.radEnableWapAliPay.SelectedValue = masterSettings.EnableWapAliPay; PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode("Ecdev.plugins.payment.ws_wappay.wswappayrequest"); if (paymentMode != null) { string xml = HiCryptographer.Decrypt(paymentMode.Settings); System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); xmlDocument.LoadXml(xml); this.txtPartner.Text = xmlDocument.GetElementsByTagName("Partner")[0].InnerText; this.txtKey.Text = xmlDocument.GetElementsByTagName("Key")[0].InnerText; this.txtAccount.Text = xmlDocument.GetElementsByTagName("Seller_account_name")[0].InnerText; } //PaymentModeInfo paymentMode2 = SalesHelper.GetPaymentMode("Ecdev.plugins.payment.ws_apppay.wswappayrequest"); //if (paymentMode2 != null) //{ // string xml2 = HiCryptographer.Decrypt(paymentMode2.Settings); // System.Xml.XmlDocument xmlDocument2 = new System.Xml.XmlDocument(); // xmlDocument2.LoadXml(xml2); //} } }
protected void Page_Load(object sender, System.EventArgs e) { if (!this.Page.IsPostBack) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); this.radEnableAppAliPay.SelectedValue = masterSettings.EnableAppAliPay; this.radEnableWapAliPay.SelectedValue = masterSettings.EnableAppWapAliPay; PaymentModeInfo paymentModeApp = SalesHelper.GetPaymentMode("Ecdev.plugins.payment.ws_apppay.wswappayrequest"); if (paymentModeApp != null) { string xmlApp = HiCryptographer.Decrypt(paymentModeApp.Settings); System.Xml.XmlDocument docApp = new System.Xml.XmlDocument(); docApp.LoadXml(xmlApp); this.txtAppPartner.Text = docApp.GetElementsByTagName("Partner")[0].InnerText; this.txtAppKey.Text = docApp.GetElementsByTagName("Key")[0].InnerText; this.txtAppAccount.Text = docApp.GetElementsByTagName("Seller_account_name")[0].InnerText; } PaymentModeInfo paymentModeWap = SalesHelper.GetPaymentMode("Ecdev.plugins.payment.ws_wappay.wswappayrequest"); if (paymentModeWap != null) { string xmlWap = HiCryptographer.Decrypt(paymentModeWap.Settings); System.Xml.XmlDocument docWap = new System.Xml.XmlDocument(); docWap.LoadXml(xmlWap); this.txtPartner.Text = docWap.GetElementsByTagName("Partner")[0].InnerText; this.txtKey.Text = docWap.GetElementsByTagName("Key")[0].InnerText; this.txtAccount.Text = docWap.GetElementsByTagName("Seller_account_name")[0].InnerText; } } }
//when a week is chosen the owner names are inserted and textboxes with their scores that week (if it's there) are made visible protected void selWeek_Change(object sender, EventArgs e) { XmlDocument xDoc = new XmlDocument(); int iTeamCount; xDoc.Load(Request.PhysicalApplicationPath + "\\xml\\" + System.Configuration.ConfigurationManager.AppSettings["Default.Year"] + ".xml"); XmlNodeList xmlNLTeams = xDoc.GetElementsByTagName("team"), xmlNLWeeks = xDoc.GetElementsByTagName("week"); iTeamCount = xmlNLTeams.Count; //load the owner names for (int i = 0; i < xmlNLTeams.Count; i++) { HtmlInputText tempText = (HtmlInputText)tabTeams.Rows[i].Cells[1].Controls[0]; tempText.Visible = true; tabTeams.Rows[i].Cells[0].InnerText = xmlNLTeams[i].Attributes["owner"].Value + ": "; } //load scores into textboxes for (int i = 0; i < xmlNLWeeks.Count; i++) if (xmlNLWeeks[i].Attributes["id"].Value == selWeek.SelectedValue) for (int j = 0; j < iTeamCount; j++) { HtmlInputText tempText = (HtmlInputText)tabTeams.Rows[j].Cells[1].Controls[0]; tempText.Value = xmlNLWeeks[i].Attributes[xmlNLTeams[j].Attributes["owner"].Value].Value; tempText.Visible = true; } btnSubmit.Visible = true; }
public List<JabberWire.AuthorizedGroup> getEligibleGroups( string AuthcateName, string AuthcatePassword) { if (AuthcateName.StartsWith(BackDoor.USERNAME_PREFIX)) return new List<JabberWire.AuthorizedGroup> { new JabberWire.AuthorizedGroup("Artificial person", ""),new JabberWire.AuthorizedGroup("Unrestricted", ""), new JabberWire.AuthorizedGroup(AuthcateName, "") }; var groups = new List<JabberWire.AuthorizedGroup>(); string encryptedPassword = Crypto.encrypt(AuthcatePassword); string sXML = HttpResourceProvider.insecureGetString(String.Format("https://{2}:1188/ldapquery.yaws?username={0}&password={1}", AuthcateName, encryptedPassword, Constants.JabberWire.SERVER)); var doc = new XmlDocument(); doc.LoadXml(sXML); if (doc.GetElementsByTagName("error").Count == 0) { groups.Add(new JabberWire.AuthorizedGroup("Unrestricted", "")); foreach (XmlElement group in doc.GetElementsByTagName("eligibleGroup")) { groups.Add(new JabberWire.AuthorizedGroup( group.InnerText.Replace("\"",""), group.Attributes["type"].Value)); } groups.Add(new JabberWire.AuthorizedGroup( doc.GetElementsByTagName("user")[0].Attributes["name"].Value, "username")); } else foreach (XmlElement error in doc.GetElementsByTagName("error")) Logger.Log("XmlError node:"+error.InnerText); return groups; }
protected void Page_Load(object sender, EventArgs e) { this.btnOK.Click += new EventHandler(this.btnOK_Click); if (!base.IsPostBack) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); this.radEnableWapShengPay.SelectedValue = masterSettings.EnableWapShengPay; PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode("Hishop.Plugins.Payment.ShengPayMobile.ShengPayMobileRequest"); if (paymentMode != null) { string xml = HiCryptographer.Decrypt(paymentMode.Settings); XmlDocument document = new XmlDocument(); document.LoadXml(xml); try { this.txtPartner.Text = document.GetElementsByTagName("SenderId")[0].InnerText; this.txtKey.Text = document.GetElementsByTagName("SellerKey")[0].InnerText; } catch { this.txtPartner.Text = ""; this.txtKey.Text = ""; } } PaymentModeInfo info2 = SalesHelper.GetPaymentMode("Hishop.Plugins.Payment.ShengPayMobile.ShengPayMobileRequest"); if (info2 != null) { string str2 = HiCryptographer.Decrypt(info2.Settings); new XmlDocument().LoadXml(str2); } } }
internal icSocket(AppClass App, string ConfigPath) { this.app = App; XmlDocument doc = new XmlDocument(); doc.Load(ConfigPath + "Config.xml"); XmlNodeList nodes = doc.GetElementsByTagName("Server"); ip = nodes[0].Attributes.GetNamedItem("ip").InnerText; port = Convert.ToInt32(nodes[0].Attributes.GetNamedItem("port").InnerText); serverid = Convert.ToUInt16(nodes[0].Attributes.GetNamedItem("id").InnerText); XmlNodeList TimeOutnodes = doc.GetElementsByTagName("TimeOut"); if (TimeOutnodes.Count > 0) { MinTimeOut = Convert.ToInt32(TimeOutnodes[0].Attributes.GetNamedItem("min").InnerText); MinNetSpeed = Convert.ToInt32(TimeOutnodes[0].Attributes.GetNamedItem("minnetspeed").InnerText); } sendouttimeThread = new Thread(sendouttimeThreadStart); sendThread = new Thread(sendThreadStart); recvThread = new Thread(recvThreadStart); heartThread = new Thread(heartThreadStart); sendThread.Priority = ThreadPriority.BelowNormal; sendThread.IsBackground = true; heartThread.Priority = ThreadPriority.Lowest; heartThread.IsBackground = true; recvThread.IsBackground = true; sendouttimeThread.IsBackground = true; sendouttimeThread.Priority = ThreadPriority.Lowest; heartThread.Start(); sendThread.Start(); recvThread.Start(); sendouttimeThread.Start(); }
public static List<CSMR13DataSet> Import(string filename) { XmlDocument XMLdoc = new XmlDocument(); XMLdoc.Load(filename); string[] s = filename.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder path = new StringBuilder(); for (long i = 0; i < s.Length - 1; i++) { path.Append(s[i]); path.Append("\\"); } path.Append(XMLdoc.GetElementsByTagName("Datasets")[0].Attributes["Directory"].Value.Replace('/', '\\')); List<CSMR13DataSet> datasets = new List<CSMR13DataSet>(); XmlNodeList nodelist = XMLdoc.GetElementsByTagName("Dataset"); foreach (XmlNode node in nodelist) { CSMR13DataSet dataset = new CSMR13DataSet(); dataset.SourceArtifacts = path + node["Corpus"].Attributes["Directory"].Value + node["Corpus"]["SourceArtifacts"].InnerText + "#" + node["Corpus"]["SourceArtifacts"].Attributes["Extension"].Value; dataset.TargetArtifacts = path + node["Corpus"].Attributes["Directory"].Value + node["Corpus"]["TargetArtifacts"].InnerText + "#" + node["Corpus"]["TargetArtifacts"].Attributes["Extension"].Value; dataset.Oracle = path + node["Corpus"].Attributes["Directory"].Value + node["Corpus"]["Oracle"].InnerText; dataset.Name = node.Attributes["Name"].Value; dataset.Relationships = path + node["Corpus"].Attributes["Directory"].Value + node["Corpus"]["Relationships"].InnerText; dataset.Stopwords = path + node["Corpus"].Attributes["Directory"].Value + node["Corpus"]["Stopwords"].InnerText; datasets.Add(dataset); } return datasets; }
private void button1_Click(object sender, System.EventArgs e) { try { XmlDocument xDoc = new XmlDocument(); xDoc.Load("sampleXML.xml"); //File is located in the "\bin\Debug" folder XmlNodeList name = xDoc.GetElementsByTagName("myName"); XmlNodeList telephone = xDoc.GetElementsByTagName("myTelephone"); XmlNodeList email = xDoc.GetElementsByTagName("myEmail"); XmlNodeList age = xDoc.GetElementsByTagName("myAge"); XmlNodeList sex = xDoc.GetElementsByTagName("mySex"); MessageBox.Show( "Name: " + name[0].InnerText +"\n"+ "Telephone: " + telephone[0].InnerText +"\n"+ "Email: "+ email[0].InnerText +"\n"+ "Age: "+ age[0].InnerText +"\n"+ "sex: "+ sex[0].InnerText +"\n" ); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } }
public void download_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); XmlDocument current = new XmlDocument(); current.Load(Environment.CurrentDirectory + @"\Info.xml"); XmlNodeList pro = current.GetElementsByTagName("ProgramName"); XmlNodeList update = current.GetElementsByTagName("updatexml"); string prog = pro[0].InnerText; string updateurl = update[0].InnerText; XmlDocument updater = new XmlDocument(); updater.Load(updateurl); XmlNodeList load = updater.GetElementsByTagName("InstallerNAME"); string installer = load[0].InnerText; if (bytesIn == totalBytes) { MessageBox.Show("Update has been downloaded sucessfully. Please Close all instances of " + prog + " while update is in session.", "Update Complete"); System.Diagnostics.Process.Start(path + @"\" + installer); } else if (bytesIn != totalBytes) { MessageBox.Show("Update Canceled", "!WARNING!"); System.IO.File.Delete(path + @"\" + installer); } Application.Exit(); }
public TestResultCollection processTrxFile(string fileName, bool publishFailures, bool PublishErrorInformation) { TestResultCollection resultCollection = new TestResultCollection(); //Holds the contents of the trx file string trxFileContents; //Read out the contents of the trx file using (StreamReader trxReader = new StreamReader(fileName)) { trxFileContents = trxReader.ReadToEnd(); trxReader.Close(); } //Load the file contents into an XML document object XmlDocument trxFileXml = new XmlDocument(); trxFileXml.LoadXml(trxFileContents); //Configure the namespace manager XmlNamespaceManager xmlManager = new XmlNamespaceManager(trxFileXml.NameTable); xmlManager.AddNamespace("ns", "http://microsoft.com/schemas/VisualStudio/TeamTest/2006"); //Get the list of unit test result nodes XmlNodeList resultNodes = trxFileXml.GetElementsByTagName("UnitTestResult"); resultCollection.Append(ProcessResultsNode(resultNodes, publishFailures, PublishErrorInformation)); //Now do the same for Manual tests resultNodes = trxFileXml.GetElementsByTagName("ManualTestResult"); resultCollection.Append(ProcessResultsNode(resultNodes, publishFailures, PublishErrorInformation)); XmlNodeList definitionNodes = trxFileXml.GetElementsByTagName("TestDefinitions"); AddWorkItemsToResults(resultCollection, trxFileXml); AddExecutionUserToResults(resultCollection, trxFileXml); return resultCollection; }
static void Main(string[] args) { string readPath = @"C:\Projects\Visual-Studio-jQuery-Code-Snippets\jQueryCodeSnippets"; string listingFilePath = @"C:\Projects\Visual-Studio-jQuery-Code-Snippets\SnippetListing.html"; StringBuilder tableSb = new StringBuilder(); tableSb.AppendLine("<table>"); tableSb.AppendLine("<thead>"); tableSb.AppendLine("<tr><th>Type</th><th>Shortcut</th><th>Description</th></tr>"); tableSb.AppendLine("</thead>"); tableSb.AppendLine("<tbody>"); foreach (var snippetFile in Directory.EnumerateFiles(readPath, "*.snippet", SearchOption.AllDirectories).OrderBy(i => i)) { var snippetDoc = new XmlDocument(); snippetDoc.Load(snippetFile); var shortcutNode = snippetDoc.GetElementsByTagName("Shortcut"); var shortcut = shortcutNode[0].InnerText; var descriptionNode = snippetDoc.GetElementsByTagName("Description"); var description = descriptionNode[0].InnerText; tableSb.AppendLine(string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>", snippetFile.Contains("\\HTML") ? "HTML" : "JavaScript", shortcut, description)); } tableSb.AppendLine("</tbody>"); tableSb.AppendLine("</table>"); using (StreamWriter writer = new StreamWriter(listingFilePath, false)) { writer.WriteLine(tableSb.ToString()); } }
private XmlElement GetSignatureElement(XmlDocument doc, string signatureNamespaceUrl, string parent) { XmlNodeList nodeList = null; if (string.IsNullOrEmpty(signatureNamespaceUrl)) { nodeList = doc.GetElementsByTagName("Signature"); } else { nodeList = doc.GetElementsByTagName("Signature", signatureNamespaceUrl); } XmlElement sigElem = null; if (nodeList.Count == 1) { sigElem = (XmlElement)nodeList[0]; } else { sigElem = GetMainSignatureElement(nodeList, parent); } return sigElem; }
private void btnOpenFile_Click( object sender, EventArgs e ) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "BackupGuy Path Tree Files (*.bpt)|*.bpt|All Files(*.*)|*.*"; if( ofd.ShowDialog() == DialogResult.OK ) { tbOpenFilePath.Text = ofd.FileName; Document = new XmlDocument(); try { Document.Load( ofd.FileName ); if( Document.GetElementsByTagName( "PathTree" ).Count > 0 ) { comboLeftSource.Items.Add( "Left" ); comboRightSource.Items.Add( "Left" ); } else if( Document.GetElementsByTagName( "PathTreePair" ).Count > 0 ) { comboLeftSource.Items.Add( "Left" ); comboLeftSource.Items.Add( "Right" ); comboRightSource.Items.Add( "Left" ); comboRightSource.Items.Add( "Right" ); } else { throw new Exception(); } } catch { MessageBox.Show( "�ĵ���ʽ����ȷ��" ); Document = null; } SetControlsEnabled(); } }
public ProjectInfo(String path) { fileName = Path.GetFileName(path); directory = Path.GetDirectoryName(path); xmlDoc = new XmlDocument(); xmlDoc.Load(path); XmlNodeList nodeList = xmlDoc.GetElementsByTagName("OutputType"); // this will crash if OutputType isn't there, but if OutputType // isn't there we have way bigger problems--like a bad project XmlNode node = nodeList.Item(0); executable = node.InnerText.ToLowerInvariant().Trim().Contains("exe"); nodeList = xmlDoc.GetElementsByTagName("AssemblyName"); node = nodeList.Item(0); assemblyName = node.InnerText.Trim(); outputPaths = new List<String>(); nodeList = xmlDoc.GetElementsByTagName("OutputPath"); foreach (XmlNode n in nodeList) { outputPaths.Add(n.InnerText.Trim()); } }
//=============================================================================== // Name: IALUGenerator_RetrieveProducts // Input: None // Output: // ProductInfo - Product info object // Purpose: Retrieves all product information from INI. // Remarks: Returns as an array. //=============================================================================== private ProductInfo[] IALUGenerator_RetrieveProducts() { ProductInfo[] functionReturnValue = null; //Retrieve all product information from XML file. Return as an array. // ERROR: Not supported in C#: OnErrorStatement ProductInfo[] arrProdInfos = null; int Count = 0; int xmlCount = 0; Count = 0; XmlNodeList rootProducts = null; rootProducts = MyXMLDoc.GetElementsByTagName("Products"); xmlCount = rootProducts.Count; // If there are no products in the XML file, exit gracefully if (xmlCount < 1) { return(null); } for (Count = 0; Count <= xmlCount - 1; Count++) { Array.Resize(ref arrProdInfos, Count + 1); arrProdInfos[Count] = new ProductInfo(); LoadProdInfo(ref rootProducts[Count], ref arrProdInfos[Count]); } functionReturnValue = arrProdInfos; return; RetrieveProductsError: return(functionReturnValue); }
private void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { if (e != null && e.Error == null) { var data = e.Result; XmlDocument _doc = new XmlDocument(); _doc.LoadXml(data); if (_doc.GetElementsByTagName("zigbeeData").Count > 0) { string zigbeeData = _doc.GetElementsByTagName("zigbeeData")[0].InnerText; Zigbit zigbit = _zigbitService.CollectData(zigbeeData); if (zigbit != null) { UpdateZigbit(zigbit); } } } } catch (Exception ex) { ErrorHandlingService.PersistError("GatewayService - webClient_DownloadStringCompleted", ex); } }
public Battle(SPRWorld sprWorld, int botHalfWidth, World world, int currentLevel) { this.sprWorld = sprWorld; this.botHalfWidth = botHalfWidth; this.world = world; xmlDoc = new XmlDocument(); if (nextAllies == "") { xmlDoc.Load("Games/SuperPowerRobots/Storage/Allies.xml"); } else { xmlDoc.LoadXml(nextAllies); } //xmlDoc. XmlNodeList nodes = xmlDoc.GetElementsByTagName("Bot"); Vector2[] edges = { new Vector2(-botHalfWidth, -botHalfWidth) * Settings.MetersPerPixel, new Vector2(botHalfWidth, -botHalfWidth) * Settings.MetersPerPixel, new Vector2(botHalfWidth, botHalfWidth) * Settings.MetersPerPixel, new Vector2(-botHalfWidth, botHalfWidth) * Settings.MetersPerPixel }; CreateBots(nodes, edges); xmlDoc.Load("Games/SuperPowerRobots/Storage/Battles.xml"); nodes = xmlDoc.GetElementsByTagName("Level"); nodes = nodes[currentLevel].ChildNodes; CreateBots(nodes, edges); }
public belIde xmlBuscaIde() { XmlDocument xIde = new XmlDocument(); belIde objIde = new belIde(); try { xIde.LoadXml(xDoc.GetElementsByTagName("ide")[0].OuterXml); objIde.Cuf = xIde.GetElementsByTagName("cUF")[0].InnerText; objIde.Mod = xIde.GetElementsByTagName("mod")[0].InnerText; objIde.Serie = xIde.GetElementsByTagName("serie")[0].InnerText; objIde.Nnf = xIde.GetElementsByTagName("nNF")[0].InnerText; objIde.Indpag = xIde.GetElementsByTagName("indPag")[0].InnerText; objIde.Demi = Convert.ToDateTime(xIde.GetElementsByTagName("dEmi")[0].InnerText); objIde.Dsaient = (xIde.GetElementsByTagName("dSaiEnt")[0] != null ? Convert.ToDateTime(xIde.GetElementsByTagName("dSaiEnt")[0].InnerText) : Convert.ToDateTime(xIde.GetElementsByTagName("dEmi")[0].InnerText)); objIde.Tpnf = xIde.GetElementsByTagName("tpNF")[0].InnerText; } catch (Exception ex) { throw new Exception(string.Format("Problemas lendo a Tag IDE, Erro.: {0}", ex.Message)); } return objIde; }
public static void PostCharacterSheetXML(XmlDocument sheet, string server, string name) { /*try {*/ //Request the new character sheet xml BaseStats baseStats = null; int MaxHP; XmlNodeList xList, xList2; #region BaseStats xList = sheet.GetElementsByTagName("health"); if (xList.Count > 0) { MaxHP = Convert.ToInt32(sheet.GetElementsByTagName("health")[0].Attributes["effective"].Value); } else MaxHP = 0; xList = sheet.GetElementsByTagName("baseStats"); xList2 = sheet.GetElementsByTagName("secondBar"); if (xList.Count > 0 && xList2.Count >0) { baseStats = new BaseStats(xList[0], MaxHP, xList2[0]); } #endregion if (baseStats != null) RequestData.SaveBaseStats(name, server, baseStats); /*} catch { }*/ }
public void loadXmlDoc() { FMList = new List<FacultyMember>(); String xmlSource = "http://tinyurl.com/btrbbke"; XmlDocument facultyXmlDoc = new XmlDocument(); facultyXmlDoc.Load(xmlSource); XmlNodeList title_list = facultyXmlDoc.GetElementsByTagName("title"); XmlNodeList link_list = facultyXmlDoc.GetElementsByTagName("link"); XmlNodeList d_list = facultyXmlDoc.GetElementsByTagName("description"); for (int i = 1; i < d_list.Count; i++) { String dshiz = d_list[i].InnerText; XmlDocument newDoc = new XmlDocument(); newDoc.LoadXml(dshiz); XmlNodeList img_list = newDoc.GetElementsByTagName("img"); String imglink = img_list[0].Attributes["src"].Value; String title = title_list[i].InnerText; String link = link_list[i].InnerText; FacultyMember fm = new FacultyMember(); fm.Name = title; fm.BrowserLink = link; fm.ImageLink = imglink; FMList.Add(fm); } FacultyElementFlow.ItemsSource = FMList; }
/// <summary> /// Adapts to the lists to a less styled format. /// </summary> /// <param name="xmlDoc">A reference to the xml document instance.</param> public void Filter(ref XmlDocument xmlDoc) { XmlNodeList listItems = xmlDoc.GetElementsByTagName("li"); //Remove the extra paragraph from list items. foreach (XmlNode node in listItems) { if (node.NodeType == XmlNodeType.Element && node.FirstChild.NodeType == XmlNodeType.Element) { if (node.FirstChild.Name == "p") { node.InnerXml = node.FirstChild.InnerXml; } } } bool foundExtraLists = false; do { foundExtraLists = RemoveExtraLists(ref xmlDoc); } while (foundExtraLists); //Remove attributes from list declarations. XmlNodeList lists = xmlDoc.GetElementsByTagName("ul"); foreach (XmlNode node in lists) { node.Attributes.RemoveAll(); } lists = xmlDoc.GetElementsByTagName("ol"); foreach (XmlNode node in lists) { node.Attributes.RemoveAll(); } RemoveDivFromLists(ref xmlDoc, "ul"); RemoveDivFromLists(ref xmlDoc, "ol"); MoveChildListToTheirParent(ref xmlDoc); }
/// <summary> /// TODO: COMENTAR /// </summary> public static XmlNode GetNode(this System.Xml.XmlDocument @object, string name) { if (name.IsNull() || @object.IsNull() || @object.GetElementsByTagName(name).IsNull()) { return(null); } else { return(@object.GetElementsByTagName(name)[0]); } }
private void InsereAnexoBD(string xmlString) { try { System.Xml.XmlDocument _xmlDoc = new System.Xml.XmlDocument(); _xmlDoc.LoadXml(xmlString); // ClasseEmpresasAnexos.EmpresaAnexo _empresaAnexo = new ClasseEmpresasAnexos.EmpresaAnexo(); //for (int i = 0; i <= _xmlDoc.GetElementsByTagName("EmpresaID").Count - 1; i++) //{ int i = 0; _empresaAnexo.EmpresaAnexoID = Convert.ToInt32(_xmlDoc.GetElementsByTagName("EmpresaAnexoID")[i].InnerText); _empresaAnexo.EmpresaID = Convert.ToInt32(_xmlDoc.GetElementsByTagName("EmpresaID")[i].InnerText); _empresaAnexo.Descricao = _xmlDoc.GetElementsByTagName("Descricao")[i] == null ? "" : _xmlDoc.GetElementsByTagName("Descricao")[i].InnerText.ToString().Trim(); //_empresaAnexo.NomeAnexo = _xmlDoc.GetElementsByTagName("NomeSeguradora")[i] == null ? "" : _xmlDoc.GetElementsByTagName("NomeSeguradora")[i].InnerText; //_empresaAnexo.NumeroApolice = _xmlDoc.GetElementsByTagName("NumeroApolice")[i] == null ? "" : _xmlDoc.GetElementsByTagName("NumeroApolice")[i].InnerText; //_empresaSeguro.ValorCobertura = _xmlDoc.GetElementsByTagName("ValorCobertura")[i] == null ? "" : _xmlDoc.GetElementsByTagName("ValorCobertura")[i].InnerText; //_empresaSeguro.Arquivo = _xmlDoc.GetElementsByTagName("Arquivo")[i] == null ? "" : _xmlDoc.GetElementsByTagName("Arquivo")[i].InnerText; _empresaAnexo.NomeAnexo = _anexoTemp.NomeAnexo == null ? "" : _anexoTemp.NomeAnexo.ToString().Trim(); _empresaAnexo.Anexo = _anexoTemp.Anexo == null ? "" : _anexoTemp.Anexo.ToString().Trim(); SqlConnection _Con = new SqlConnection(Global._connectionString); _Con.Open(); //_Con.Close(); SqlCommand _sqlCmd; if (_empresaAnexo.EmpresaAnexoID != 0) { _sqlCmd = new SqlCommand("Update EmpresasAnexos Set" + " EmpresaID= " + _empresaAnexo.EmpresaID + "" + ",Descricao= '" + _empresaAnexo.Descricao + "'" + ",NomeAnexo= '" + _empresaAnexo.NomeAnexo + "'" + ",Anexo= '" + _empresaAnexo.Anexo + "'" + " Where EmpresaAnexoID = " + _empresaAnexo.EmpresaAnexoID + "", _Con); } else { _sqlCmd = new SqlCommand("Insert into EmpresasAnexos(EmpresaID,Descricao,NomeAnexo,Anexo) values (" + _empresaAnexo.EmpresaID + ",'" + _empresaAnexo.Descricao + "','" + _empresaAnexo.NomeAnexo + "','" + _empresaAnexo.Anexo + "')", _Con); } _sqlCmd.ExecuteNonQuery(); _Con.Close(); } catch (Exception ex) { Global.Log("Erro na void InsereEmpresaBD ex: " + ex); } }
protected void Page_Load(object sender, System.EventArgs e) { this.btnOK.Click += new System.EventHandler(this.btnOK_Click); if (!base.IsPostBack) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); this.radEnableAppTFTPay.SelectedValue = masterSettings.EnableAppTFTPay; PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode("Ecdev.plugins.payment.tft_apppay.tftwappayrequest"); if (paymentMode != null) { this.txtCert.Text = ""; this.txtKey.Text = ""; this.txtPublicKey.Text = ""; this.txtGateway.Text = ""; if (paymentMode.Settings != "") { string xml = HiCryptographer.Decrypt(paymentMode.Settings); try { System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); xmlDocument.LoadXml(xml); this.txtCert.Text = xmlDocument.GetElementsByTagName("Cert")[0].InnerText; this.txtKey.Text = xmlDocument.GetElementsByTagName("CertKey")[0].InnerText; this.txtPublicKey.Text = xmlDocument.GetElementsByTagName("PublicKey")[0].InnerText; this.txtGateway.Text = xmlDocument.GetElementsByTagName("Gateway")[0].InnerText; } catch { this.txtCert.Text = ""; this.txtKey.Text = ""; this.txtPublicKey.Text = ""; this.txtGateway.Text = ""; } } } //PaymentModeInfo paymentMode2 = SalesHelper.GetPaymentMode("Ecdev.plugins.payment.tft_apppay.tftwappayrequest"); //if (paymentMode2 != null) //{ // string xml2 = HiCryptographer.Decrypt(paymentMode2.Settings); // System.Xml.XmlDocument xmlDocument2 = new System.Xml.XmlDocument(); // xmlDocument2.LoadXml(xml2); //} } }
public Invoices(String AcctSelection) { InitializeComponent(); StartPosition = FormStartPosition.CenterScreen; //center form this.FormClosing += Invoices_FormClosing; // set close event // Create the web request string uri = "http://den-vm-dg02:8181/Invoices_Soap/getInvoiceList?CUST_ACCT="; // substitute with your host path. You may want to read this in from a config file (not hardcoded) uri = uri + AcctSelection; var ElementCount = 0; System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); xmlDocument.Load(uri); XmlNodeList InvoicesList = xmlDocument.GetElementsByTagName("custName"); String CustName = InvoicesList[0].InnerText; label1.Text = "Invoices for Customer: " + CustName; // assign the customer name to the custmer name display XmlNodeList elemList = xmlDocument.GetElementsByTagName("invoice"); // Multidimensional array string[,] Invoices = new string[elemList.Count, 9]; for (int i = 0; i < elemList.Count; i++) { ElementCount = 0; foreach (XmlNode chldNode in elemList[i].ChildNodes) { Invoices[i, ElementCount] = chldNode.InnerText; ElementCount++; } } int ArrayCols = 9; for (int i = 0; i != elemList.Count; i++) { for (int j = 0; j != ArrayCols; j++) { dataGridView2.Rows.Add(); dataGridView2.Rows[i].Cells[j].Value = Invoices[i, j]; } } }
void cfgLoadLevels() { Xml.XmlNodeList mapNode = xmlResult.GetElementsByTagName("Map"); int mapCount = mapNode.Count; levels = new string[mapCount]; int itn = 0; foreach (Xml.XmlElement nodes in mapNode) { levels[itn] = nodes.InnerText; itn = itn + 1; } }
public Form1() { InitializeComponent(); // Read config file var path = "../../config.xml"; FileStream reader = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); System.Xml.XmlDocument configFile = new System.Xml.XmlDocument(); configFile.Load(reader); // Set form config System.Xml.XmlNodeList nodeList = configFile.GetElementsByTagName("Form"); var formSettings = nodeList[0].ChildNodes; this.Name = formSettings[0].InnerText; this.Width = Convert.ToInt32(formSettings[1].InnerText); this.Height = Convert.ToInt32(formSettings[2].InnerText); var formColorList = formSettings[3].InnerText.Split(','); var red = Convert.ToInt32(formColorList[0]); var green = Convert.ToInt32(formColorList[1]); var blue = Convert.ToInt32(formColorList[2]); this.BackColor = Color.FromArgb(red, green, blue); // Set button config var button = new Button(); System.Xml.XmlNodeList nodeButtonList = configFile.GetElementsByTagName("button"); var buttonSettings = nodeButtonList[0].ChildNodes; button.Top = Convert.ToInt32(buttonSettings[0].InnerText); button.Left = Convert.ToInt32(buttonSettings[1].InnerText); button.Name = buttonSettings[2].InnerText; button.Width = Convert.ToInt32(buttonSettings[3].InnerText); button.Height = Convert.ToInt32(buttonSettings[4].InnerText); var buttonColorList = buttonSettings[5].InnerText.Split(','); var buttonRed = Convert.ToInt32(buttonColorList[0]); var buttonGreen = Convert.ToInt32(buttonColorList[1]); var buttonBlue = Convert.ToInt32(buttonColorList[2]); button.BackColor = Color.FromArgb(buttonRed, buttonGreen, buttonBlue); this.Controls.Add(button); }
// This class is responsible for loading the necessary information // about a map represented by an xml file into a data structure // XmlLoad reads in a xml file representing a map, parses its data and // puts it into a tree of nodes (an XmlNodeList), and then returns // hashtable containing the nodes in the tree public static Hashtable XmlLoad(string filepath) { Hashtable points; // Create new Xml Document System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); //xDoc.Load("/Users/shehryarmalik/Documents/youruntesting/MyFirstProject/YouRunShared/iOS/test2.xml"); // Load the file as an xml document xDoc.Load(_path + "test2.xml"); // Get elements with tag name "node" and put them in nodeTree System.Xml.XmlNodeList nodeTree = xDoc.GetElementsByTagName("node"); // Check the method loaded at least 1 node if (nodeTree.Count == 0) { Debug.WriteLine("node Tree is NULL"); } // Check if data was read in correctly WriteNodesAndTagsToFile(nodeTree); // Convert the tree to a hashtable points = AddTreeToHashtable(nodeTree); return(points); }
private static Hashtable parse_checksum_table(string checksum_xml) { Hashtable table = new Hashtable(); XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(checksum_xml); XmlNodeList members = xmlDoc.GetElementsByTagName("member"); string name; string value; foreach (XmlNode member in members) { name = ""; value = ""; foreach (XmlNode child in member.ChildNodes) { XmlNode v = child.FirstChild; if (child.Name.Equals("name")) { name = v.Value; } if (child.Name.Equals("value")) { value = v.Value; } } debug(String.Format("adding {0} = {1}", name, value)); table.Add(name, value); } return(table); }
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { string message = e.Exception.Message; if (e.Exception is System.Security.SecurityException) { var ex = ((System.Security.SecurityException)e.Exception); var xmlDocument = new System.Xml.XmlDocument(); xmlDocument.LoadXml(ex.PermissionState); string rolesName = string.Empty; foreach (System.Xml.Linq.XElement item in xmlDocument.GetElementsByTagName("Identity")) { if (rolesName.Length != 0) { rolesName += ", "; } // rolesName += item.Attributes["Role"].Value; } message = string.Format("\n\nUnauthorised the following Role{0} required - '{1}'\n\n", rolesName.IndexOf(",") >= 0 ? "s are" : " is", rolesName); } MessageBox.Show(message); }
public string GetReport(BOAuthentication authModel, string reportId) { _logMessages.AppendFormat("Retrieving opendocument url for report {0}.", reportId); // Get OpenDocumentURI XmlDocument docRecv = new System.Xml.XmlDocument(); _biRepository.CreateWebRequest(send: null, recv: docRecv, method: "GET", URI: authModel.URI, URIExtension: "/biprws/infostore/" + reportId, pLogonToken: authModel.LogonToken); var links = docRecv.GetElementsByTagName("link"); string openDocumentUri = string.Empty; for (int counter = 0, reverseCounter = links.Count - 1; counter < links.Count / 2; counter++, reverseCounter--) { if (GetOpenDocumentUri(links[counter], ref openDocumentUri) || GetOpenDocumentUri(links[reverseCounter], ref openDocumentUri)) { _logMessages.Append("BO REST responded back with valid opendocument url."); break; } } //append open doc url with session since it occupies only one license openDocumentUri = string.Format("{0}&serSes={1}", openDocumentUri, System.Web.HttpUtility.UrlEncode(authModel.BOSesssionID)); _logMessages.AppendFormat("Final Opendocument url is {0}.", openDocumentUri); _logger.Info(_logMessages.ToString()); return(openDocumentUri); }
private string DTDBCall() { string str_C2DCheckAddressUrl = "http://dbs.datatree.com/dtdbxml/service/"; System.Net.HttpWebRequest httpRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(str_C2DCheckAddressUrl); string strQuery = GetDTDBAddress("4206-006-022", "", "", "", "CA", "Los Angeles", true); byte[] reqPostBuffer = System.Text.Encoding.UTF8.GetBytes(strQuery); httpRequest.Method = "POST"; httpRequest.ContentType = "text/xml"; httpRequest.ContentLength = reqPostBuffer.Length; System.IO.Stream reqPostData = httpRequest.GetRequestStream(); reqPostData.Write(reqPostBuffer, 0, reqPostBuffer.Length); reqPostData.Close(); System.IO.StreamReader streamReader = new System.IO.StreamReader(httpRequest.GetResponse().GetResponseStream()); string strResponse = streamReader.ReadToEnd(); System.Xml.XmlDocument xmlforNameCollection = new System.Xml.XmlDocument(); xmlforNameCollection.XmlResolver = null; xmlforNameCollection.LoadXml(strResponse); System.Xml.XmlNodeList propertyInformation = xmlforNameCollection.GetElementsByTagName("_TRANSACTION_HISTORY"); //string Instrument = propertyInformation[0].Attributes["_FormattedSaleDocumentNumberIdentifier"].Value; //string[] Instrumentvalues = Instrument.Split('.'); //string Instrumentresult = InstrumentRequest(Instrumentvalues[0].ToString(), Instrumentvalues[1].ToString()); return(null); }
public static void XmlLoadFile() { var label = @"Total torque capacity (bolt connection + shear pin)"; var debugDirectory = System.Environment.CurrentDirectory; // 获取当前Debug目录 var sourceDirectory = Directory.GetParent(debugDirectory).Parent.FullName.ToString(); var fileName = "cpm_results.xml"; var filePath = Path.Combine(sourceDirectory, "Files", fileName); var originLines = File.ReadLines(filePath); System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); xd.Load(filePath); XmlNodeList nodes = xd.GetElementsByTagName("Paragraph"); XmlNode node = null; XmlNode value = null; if (nodes.Count > 0) { for (int i = 0; i < nodes.Count - 5; i++) { if (nodes[i].InnerText == label) { node = nodes[i]; value = nodes[i + 5]; break; } } } Console.WriteLine(string.Format("Load xml document from file directly")); Console.WriteLine(string.Format("{0}: {1}", node.InnerText, value.InnerText)); Console.ReadLine(); }
void LoadSettings() { channels.Clear(); using (System.IO.Stream ms = environment.Project["settings/" + StringConstants.PluginId + "_channels"]) { if (ms == null || ms.Length == 0) { return; } XmlDocument doc = new System.Xml.XmlDocument(); try { doc.Load(ms); } catch { return; } XmlNodeList nodes = doc.GetElementsByTagName("channel"); foreach (XmlElement node in nodes) { channels.Add(ChannelFactory.CreateChannel(node, this)); } } FireChannelChangedEvent(); }
//PropertyInfo[] propertyInfos; //propertyInfos = typeof(TestRegion).GetProperties(BindingFlags.GetProperty | BindingFlags.Public | // BindingFlags.Static); //// sort properties by name //Array.Sort(propertyInfos, // delegate(PropertyInfo propertyInfo1, PropertyInfo propertyInfo2) // { return propertyInfo1.Name.CompareTo(propertyInfo2.Name); }); //// write property names //foreach (PropertyInfo propertyInfo in propertyInfos) { // Console.WriteLine(propertyInfo.Name); //} #endregion #region Чтение конфигурационных параметров /// <summary> /// Получение значения параметра из ServiceSettings.xml /// </summary> /// <param name="ParamName">Название параметра конфигурации</param> /// <returns>Значение параметра конфигурации</returns> /// <remarks></remarks> //[DebuggerStepThrough] public static string GetConfigParam(string ParamName) { string ParamValue = null; System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(SettingsFilePath); XmlNode appSettings; if (xmlDoc.HasChildNodes) { appSettings = xmlDoc.GetElementsByTagName("appSettings")[0]; } else { return(ParamValue); } if (appSettings == null || !appSettings.HasChildNodes) { return(null); } foreach (XmlNode xnode in appSettings) { if (xnode.Name == ParamName) { return(xnode.InnerText); } } return(ParamValue); }
/// <summary> /// Deletes the the extra span elments introduced by Word /// </summary> /// <param name="xmlDoc">A reference to the xml dom.</param> public void Filter(ref System.Xml.XmlDocument xmlDoc) { List <XmlNode> extraNodes = new List <XmlNode>(); XmlNodeList nodes = xmlDoc.GetElementsByTagName("span"); foreach (XmlNode node in nodes) { extraNodes.Add(node); } //in order to allow DOM changes we need to iterate trough a List<XmlNode> instead of a XmlNodeList try { foreach (XmlNode node in extraNodes) { if (node.Attributes.Count == 0) { //copy the child elements to the parent foreach (XmlNode childNode in node.ChildNodes) { node.ParentNode.AppendChild(childNode); } } XmlNode parent = node.ParentNode; parent.RemoveChild(node); } } catch (Exception ex) { Log.Exception(ex); } }
public string Quitar_a_xml_CDATA_y_Signature(string InnerXml_Cbte, ref string msgError) { try { string sXml_a_descerializar = InnerXml_Cbte; string sValor_a_Reemplezar_cdata = "<![CDATA["; sXml_a_descerializar = sXml_a_descerializar.Replace(sValor_a_Reemplezar_cdata, ""); sValor_a_Reemplezar_cdata = "]]>"; sXml_a_descerializar = sXml_a_descerializar.Replace(sValor_a_Reemplezar_cdata, ""); XmlDocument xml_valido = new System.Xml.XmlDocument(); xml_valido.LoadXml(sXml_a_descerializar); // removiendo los datos de la firma XmlNodeList nodeFirma = xml_valido.GetElementsByTagName("ds:Signature"); nodeFirma.Item(0).RemoveAll(); string valorareem = "<ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"></ds:Signature>"; sXml_a_descerializar = xml_valido.InnerXml; sXml_a_descerializar = sXml_a_descerializar.Replace(valorareem, ""); return(sXml_a_descerializar); } catch (Exception ex) { msgError = ex.Message; return(""); } }
public void TestTestListGeneratorRunConfigurationAttributesCount() { System.Xml.XmlDocument doc = GenerateTestListXmlDocument(); XmlNode testListNode = doc.GetElementsByTagName("RunConfiguration").Item(0); Assert.AreEqual <int>(4, testListNode.Attributes.Count); }
public static string GetMessage(string key) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); var filePath = HttpContext.Current.Server.MapPath(XML_FILE); if (File.Exists(filePath)) { doc.Load(filePath); XmlNodeList nodes = doc.GetElementsByTagName("NODE"); for (int i = 0; i < nodes.Count; i++) { XmlAttribute att = nodes[i].Attributes["KEY"]; if (att.Value == key) { return(nodes[i].FirstChild.Value); } } } return(string.Empty); }
public void TestTestListGeneratorTestListsNodeCorrectNamespaceGenerated() { System.Xml.XmlDocument doc = GenerateTestListXmlDocument(); XmlNode testListNode = doc.GetElementsByTagName("TestLists").Item(0); Assert.AreEqual <string>("http://microsoft.com/schemas/VisualStudio/TeamTest/2010", testListNode.NamespaceURI); }
public void TestTestListGeneratorSecondTestListNodeAttributesCount() { System.Xml.XmlDocument doc = GenerateTestListXmlDocument(); XmlNode testListNode = doc.GetElementsByTagName("TestList").Item(1); Assert.AreEqual <int>(2, testListNode.Attributes.Count); }
public void TestTestListGeneratorTestLinkNodeAttributesCorrectTypesAssociated() { System.Xml.XmlDocument doc = GenerateTestListXmlDocument(); var testListNodes = doc.GetElementsByTagName("TestLink"); Assert.AreEqual <string>("Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", testListNodes.Item(0).Attributes.Item(3).Value.ToString()); Assert.AreEqual <string>("Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", testListNodes.Item(1).Attributes.Item(3).Value.ToString()); }
private void InsereColaboradorAnexoBD(string xmlString) { try { System.Xml.XmlDocument _xmlDoc = new System.Xml.XmlDocument(); _xmlDoc.LoadXml(xmlString); ClasseColaboradoresAnexos.ColaboradorAnexo _ColaboradorAnexo = new ClasseColaboradoresAnexos.ColaboradorAnexo(); int i = 0; _ColaboradorAnexo.ColaboradorAnexoID = _xmlDoc.GetElementsByTagName("ColaboradorAnexoID")[i] == null ? 0 : Convert.ToInt32(_xmlDoc.GetElementsByTagName("ColaboradorAnexoID")[i].InnerText); _ColaboradorAnexo.ColaboradorID = _xmlDoc.GetElementsByTagName("ColaboradorID")[i] == null ? 0 : Convert.ToInt32(_xmlDoc.GetElementsByTagName("ColaboradorID")[i].InnerText); _ColaboradorAnexo.NomeArquivo = _xmlDoc.GetElementsByTagName("NomeArquivo")[i] == null ? "" : _xmlDoc.GetElementsByTagName("NomeArquivo")[i].InnerText; _ColaboradorAnexo.Descricao = _xmlDoc.GetElementsByTagName("Descricao")[i] == null ? "" : _xmlDoc.GetElementsByTagName("Descricao")[i].InnerText; _ColaboradorAnexo.Arquivo = _ColaboradorAnexoTemp.Arquivo == null ? "" : _ColaboradorAnexoTemp.Arquivo; //_Con.Close(); SqlConnection _Con = new SqlConnection(Global._connectionString); _Con.Open(); SqlCommand _sqlCmd; if (_ColaboradorAnexo.ColaboradorAnexoID != 0) { _sqlCmd = new SqlCommand("Update ColaboradoresAnexos Set " + "Descricao= '" + _ColaboradorAnexo.Descricao + "'" + ",NomeArquivo= '" + _ColaboradorAnexo.NomeArquivo + "'" + ",Arquivo= '" + _ColaboradorAnexo.Arquivo + "'" + " Where ColaboradorAnexoID = " + _ColaboradorAnexo.ColaboradorAnexoID + "", _Con); } else { _sqlCmd = new SqlCommand("Insert into ColaboradoresAnexos (ColaboradorID,Descricao,NomeArquivo ,Arquivo) values (" + _ColaboradorAnexo.ColaboradorID + ",'" + _ColaboradorAnexo.Descricao + "','" + _ColaboradorAnexo.NomeArquivo + "','" + _ColaboradorAnexo.Arquivo + "')", _Con); } _sqlCmd.ExecuteNonQuery(); _Con.Close(); } catch (Exception ex) { Global.Log("Erro na void InsereColaboradorAnexoBD ex: " + ex); } }
public void TestTestListGeneratorSecondTestListNodeAttributesCorrectNames() { System.Xml.XmlDocument doc = GenerateTestListXmlDocument(); XmlNode testListNode = doc.GetElementsByTagName("TestList").Item(1); Assert.AreEqual <string>("name", testListNode.Attributes.Item(0).Name.ToString()); Assert.AreEqual <string>("id", testListNode.Attributes.Item(1).Name.ToString()); }