Example #1
0
    public void LoadPlayerGame(String gamePage)
    {
        DateTime gameDate = DateTime.MinValue;

        String HTML = GetPageHTML(gamePage);

        //lets get it into XML to make it easier to read
        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        doc.LoadXml(HTML);

        //get the game date
        System.Xml.XmlNodeList nodes = doc.SelectNodes("/html/body/table/tr/td/table/tr/td/table/tr/td/table[@id='GameInfo']");
        if (nodes.Count == 0)
            nodes = doc.SelectNodes("/XMLFile/html/body/table/tr/td/table/tr/td/table/tr/td/table[@id='GameInfo']");
        foreach (System.Xml.XmlNode node in nodes)
        {
            String dateString = node.ChildNodes[3].ChildNodes[0].InnerText;
            gameDate = Convert.ToDateTime(dateString);
        }

        nodes = doc.SelectNodes("/html/body/table/tr/td/table/tr/td");
        if (nodes.Count == 0)
           nodes = doc.SelectNodes("/XMLFile/html/body/table/tr/td/table/tr/td");
        foreach (System.Xml.XmlNode node in nodes)
        {
            if (node.InnerText.Trim() == "COLORADO AVALANCHE")
            {
                RecordPlayerGamesFromTeamTable(node.ParentNode.ParentNode, gameDate, gamePage);
                break;
            }
        }
    }
        public void initialize()
        {
            string startupPath = System.IO.Directory.GetCurrentDirectory();
            XmlDocument doc = new XmlDocument();

            try
            {
                //Get the credentials from the CredentialsToUse.xml file it is in <project>/bin/Debug folder
                doc.Load(startupPath + "../../../CredentialsToUse.xml");
                email = doc.SelectNodes("//email").Item(0).InnerText;
                password = doc.SelectNodes("//password").Item(0).InnerText;
            }

            catch (FileNotFoundException ex) {
                Console.WriteLine(ex.Message + "\n File with credentials wasn't found! Assign variables explicitly");
            }

            catch (TypeLoadException ex)
            {
                Console.WriteLine(ex.Message + "\n File with credentials wasn't load! Wrong format? Assign variables explicitly");
            }

            if (String.IsNullOrWhiteSpace(email) || String.IsNullOrWhiteSpace(password))
            {
                //If you don't use an xml file assign your data to varibles email and password expilicitly
                email = "enter email";
                password = "enter password";
            }

            CustomMethods.webDriver = new FirefoxDriver();
        }
 private void Deserialize(string configXml)
 {
     if (!String.IsNullOrEmpty(configXml))
     {
         var xmlDoc = new XmlDocument();
         xmlDoc.LoadXml(configXml);
         foreach (XmlElement xmlItem in xmlDoc.SelectNodes("/EventQueueConfig/PublishedEvents/Event"))
         {
             var oPublishedEvent = new PublishedEvent();
             oPublishedEvent.EventName = xmlItem.SelectSingleNode("EventName").InnerText;
             oPublishedEvent.Subscribers = xmlItem.SelectSingleNode("Subscribers").InnerText;
             PublishedEvents.Add(oPublishedEvent.EventName, oPublishedEvent);
         }
         foreach (XmlElement xmlItem in xmlDoc.SelectNodes("/EventQueueConfig/EventQueueSubscribers/Subscriber"))
         {
             var oSubscriberInfo = new SubscriberInfo();
             oSubscriberInfo.ID = xmlItem.SelectSingleNode("ID").InnerText;
             oSubscriberInfo.Name = xmlItem.SelectSingleNode("Name").InnerText;
             oSubscriberInfo.Address = xmlItem.SelectSingleNode("Address").InnerText;
             oSubscriberInfo.Description = xmlItem.SelectSingleNode("Description").InnerText;
             oSubscriberInfo.PrivateKey = xmlItem.SelectSingleNode("PrivateKey").InnerText;
             EventQueueSubscribers.Add(oSubscriberInfo.ID, oSubscriberInfo);
         }
     }
 }
		/// <summary>
		/// Initialisiert eine neue Instanz der <see cref="changelogDocument"/>-Klasse.
		/// </summary>
		/// <param name="changelogXml"></param>
		public changelogDocument(XmlDocument changelogXml) {
#pragma warning disable
			changelogItems = new List<changelogDocumentItem>();
			rawChangelog = changelogXml;

			XmlNodeList changeNodes = changelogXml.SelectNodes("updateSystemDotNet.Changelog/Items/Item");

			if (changeNodes.Count > 0)
				germanChanges = changeNodes[0].SelectSingleNode("Change").InnerText;
			if (changeNodes.Count > 1)
				englishChanges = changeNodes[1].SelectSingleNode("Change").InnerText;

			foreach (XmlNode node in changelogXml.SelectNodes("updateSystemDotNet.Changelog/Items/Item")) {
				try {
					changelogItems.Add(new changelogDocumentItem(
					                   	node.SelectSingleNode("Developer").InnerText,
					                   	node.SelectSingleNode("Type").InnerText,
					                   	node.SelectSingleNode("Language").InnerText,
					                   	node.SelectSingleNode("Change").InnerText
					                   	));
#pragma warning enable
				}
				catch (NullReferenceException) {
				}
			}
		}
Example #5
0
        public Combinacion getCombinacionGanadora()
        {
            Combinacion combinacionGanadora = new Combinacion();
            combinacionGanadora.Ganadora = true;

            if (cargarXML())
            {
                documento = new XmlDocument();
                documento.Load(fichero);
                raiz = documento.DocumentElement;

                XmlNodeList nodesNumeros = documento.SelectNodes("Juego/CombinacionGanadora/Resultado[@numero]");
                foreach (XmlNode nodo in nodesNumeros)
                {
                    combinacionGanadora.Numeros.Add(Int32.Parse(nodo.Attributes["numero"].Value));
                }
                XmlNodeList nodesEstrellas = documento.SelectNodes("Juego/CombinacionGanadora/Resultado[@estrella]");

                foreach (XmlNode nodo in nodesEstrellas)
                {
                    combinacionGanadora.Estrellas.Add(Int32.Parse(nodo.Attributes["estrella"].Value));
                }

            }
            else
            {
                return null;
            }

            return combinacionGanadora;
        }
Example #6
0
        protected void Backup()
        {
            Dictionary<string, string> elements = new Dictionary<string, string>();
            elements.Add("Value1", "new_value1");

            //Word app = new Word(@"C:\Users\Derice\Desktop\abc.xml");

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(@"C:\Users\Derice\Desktop\abc.xml");

            XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xmlDoc.NameTable);
            namespaceManager.AddNamespace("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");

            XmlNodeList nodeList = xmlDoc.SelectNodes("//w:tbl/w:tr/w:tc/w:p/w:r/w:t[text()='Value4']", namespaceManager);
            XmlNodeList nodeBookmark = xmlDoc.SelectNodes("//w:tbl/w:tr/w:tc/w:p/w:bookmarkStart[@w:name='tblTest']", namespaceManager);
            if (nodeBookmark.Count == 1) Console.WriteLine("Huat ar.."); Console.Read();
            if (nodeList.Count == 1)
            {
                XmlNode trNode = nodeList[0].ParentNode.ParentNode.ParentNode.ParentNode;
                XmlNode tblNode = trNode.ParentNode;
                XmlNode cloneNode = trNode.Clone();
                cloneNode.InnerXml = cloneNode.InnerXml.Replace("Value4", "new_Value4");
                tblNode.InsertBefore(cloneNode, tblNode.LastChild);
                xmlDoc.Save(@"C:\Users\Derice\Desktop\temp.xml");
            }
        }
Example #7
0
        public Combinacion getCombinacionGanadora()
        {
            Combinacion combinacionGanadora = new Combinacion();
            combinacionGanadora.Ganadora = true;

            if (cargarXML())
            {
                documento = new XmlDocument();
                documento.Load(fichero);
                raiz = documento.DocumentElement;

               // string busqueda = "Juego/CombinacionGanadora/Resultado[@id=\"1\"]";
                //XmlNode valor1 = documento.SelectSingleNode("Juego/CombinacionGanadora/Resultado[@id=\"1\"]");
                //combinacionGanadora.Numero1 = valor1.Attributes["numero"].Value;
                // XmlNode valor2 = documento.SelectSingleNode("Juego/CombinacionGanadora/Resultado[@id=\"2\"]");

                XmlNodeList nodesNumeros = documento.SelectNodes("Juego/CombinacionGanadora/Resultado[@numero]");
                foreach (XmlNode nodo in nodesNumeros)
                {
                    combinacionGanadora.Numeros.Add(Int32.Parse(nodo.Attributes["numero"].Value));
                }
                XmlNodeList nodesEstrellas = documento.SelectNodes("Juego/CombinacionGanadora/Resultado[@estrella]");



            }
            else
            {
                return null;
            }

            return combinacionGanadora;
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FeatureSourceDescription"/> class.
        /// </summary>
        /// <param name="stream">The stream.</param>
        public FeatureSourceDescription(System.IO.Stream stream)
        {
            List<FeatureSchema> schemas = new List<FeatureSchema>();

            XmlDocument doc = new XmlDocument();
            doc.Load(stream);

            XmlNamespaceManager mgr = new XmlNamespaceManager(doc.NameTable);
            mgr.AddNamespace("xs", XmlNamespaces.XS); //NOXLATE
            mgr.AddNamespace("gml", XmlNamespaces.GML); //NOXLATE
            mgr.AddNamespace("fdo", XmlNamespaces.FDO); //NOXLATE

            //Assume XML configuration document
            XmlNodeList schemaNodes = doc.SelectNodes("fdo:DataStore/xs:schema", mgr); //NOXLATE
            if (schemaNodes.Count == 0) //Then assume FDO schema
                schemaNodes = doc.SelectNodes("xs:schema", mgr); //NOXLATE

            foreach (XmlNode sn in schemaNodes)
            {
                FeatureSchema fs = new FeatureSchema();
                fs.ReadXml(sn, mgr);
                schemas.Add(fs);
            }
            this.Schemas = schemas.ToArray();
        }
Example #9
0
 /// <summary>
 /// Gets a ping back
 /// </summary>
 /// <param name="Request">The HttpRequest for this item</param>
 /// <returns>The ping back message</returns>
 public static PingBackMessage GetPingBack(HttpRequest Request)
 {
     try
     {
         PingBackMessage TempMessage = new PingBackMessage();
         TempMessage.Source = "";
         TempMessage.Target = "";
         string RequestText = GetRequest(Request);
         if (!RequestText.Contains("<methodName>pingback.ping</methodName>"))
         {
             return TempMessage;
         }
         XmlDocument XMLDocument = new XmlDocument();
         XMLDocument.LoadXml(RequestText);
         XmlNodeList Nodes = XMLDocument.SelectNodes("methodCall/params/param/value/string");
         if (Nodes == null)
         {
             Nodes = XMLDocument.SelectNodes("methodCall/params/param/value");
         }
         if (Nodes != null)
         {
             TempMessage.Source = Nodes[0].InnerText.Trim();
             TempMessage.Target = Nodes[1].InnerText.Trim();
         }
         return TempMessage;
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #10
0
 public XmlDocument AddItem(string templateFile, XmlNode addNode, int addPage)
 {
     XmlDocument owner = null;
     XmlDocument document2;
     try
     {
         owner = new XmlDocument();
         owner.Load(templateFile);
         XmlNodeList list = owner.SelectNodes("jobform/layout/page");
         for (int i = list.Count; i < addPage; i++)
         {
             XmlNode node = owner.SelectSingleNode("jobform/layout");
             node.AppendChild(this.createPageNode(node.OwnerDocument, 0));
             this.appendPageTitle(owner, node.ChildNodes[i]);
             list = owner.SelectNodes("jobform/layout/page");
         }
         XmlNode node1 = list[addPage - 1];
         node1.InnerXml = node1.InnerXml + addNode.InnerXml;
         document2 = owner;
     }
     catch (NaccsException)
     {
         throw;
     }
     catch (Exception exception)
     {
         throw new NaccsException(MessageKind.Error, 0x261, exception.Message);
     }
     return document2;
 }
Example #11
0
        static void ParseXML(XmlDocument xmldoc)
        {
            Generator gen = new Generator();

            foreach (XmlNode node in xmldoc.SelectNodes("/GCC_XML/Enumeration"))
            {
                gen.InsertNode(xmldoc, node, null);
            }

            foreach (XmlNode node in xmldoc.SelectNodes("/GCC_XML/Struct"))
            {
                gen.InsertNode(xmldoc, node, null);
            }

            foreach (XmlNode node in xmldoc.SelectNodes("/GCC_XML/Class"))
            {
                gen.InsertNode(xmldoc, node, null);
            }

            foreach (XmlNode node in xmldoc.SelectNodes("/GCC_XML/File"))
            {
                gen.InsertNode(xmldoc, node, null);
            }

            gen.WriteToFile(null);
        }
Example #12
0
		public TestExecuter(string configFile)
		{
			Logger logger = new Logger();
			this.context = new Context(this, logger);
			XmlDocument testConfig = new XmlDocument();
			testConfig.Load(configFile);

			// Get test name...
			XmlNode nameNode = testConfig.SelectSingleNode("/TestCase/@testName");
			if ( null != nameNode )
			{
				this.testName = nameNode.Value;
			}

			logger.WriteLine(" ");
			logger.WriteLine(new string('-', 79));
			logger.WriteLine("                                   S T A R T" );
			logger.WriteLine( " " );
			string userName = GetUserName();
			logger.WriteLine(string.Format("Test: {0} started @ {1} by {2}", this.testName, GetNow(), userName));
			logger.WriteLine(new string('-', 79));

			// Get test setup / execution / teardown steps
			this.setupSteps = testConfig.SelectNodes("/TestCase/TestSetup/*");
			this.executeSteps = testConfig.SelectNodes("/TestCase/TestExecution/*");
			this.teardownSteps = testConfig.SelectNodes("/TestCase/TestCleanup/*");

			this.logger = logger;
		}
        /// <summary>
        /// Builds an <see cref="XmlLocalizationDictionary"/> from given xml string.
        /// </summary>
        /// <param name="xmlString">XML string</param>
        internal static XmlLocalizationDictionary BuildFomXmlString(string xmlString)
        {
            var settingsXmlDoc = new XmlDocument();
            settingsXmlDoc.LoadXml(xmlString);

            var localizationDictionaryNode = settingsXmlDoc.SelectNodes("/localizationDictionary");
            if (localizationDictionaryNode == null || localizationDictionaryNode.Count <= 0)
            {
                throw new AbpException("A Localization Xml must include localizationDictionary as root node.");
            }

            var dictionary = new XmlLocalizationDictionary(new CultureInfo(localizationDictionaryNode[0].GetAttributeValue("culture")));

            var textNodes = settingsXmlDoc.SelectNodes("/localizationDictionary/texts/text");
            if (textNodes != null)
            {
                foreach (XmlNode node in textNodes)
                {
                    var name = node.GetAttributeValue("name");
                    var value = node.GetAttributeValue("value");
                    if (string.IsNullOrEmpty(name))
                    {
                        throw new AbpException("name attribute of a text is empty in given xml string.");
                    }

                    dictionary[name] = value;
                }
            }

            return dictionary;
        }
Example #14
0
        //Write a program that extracts all different artists, which are found in the catalog.xml.
        //For each artist print the number of albums in the catalogue.
        //Use the XPath and a Dictionary<string,int> (use the artist name as key and the number of albums as value in the dictionary).
        static void Main()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("../../../catalog.xml");
            var artists = new Dictionary<string, int>();
            string xPathQueryArtists = "/albums/album/artist";
            string xPathQueryAlbums = "/albums/album/name";
            XmlNodeList artistsList = doc.SelectNodes(xPathQueryArtists);
            XmlNodeList albumList = doc.SelectNodes(xPathQueryAlbums);
            foreach (XmlNode artist in artistsList)
            {
                string artistName = artist.InnerText;
                int numOfAlbums = albumList
                    .Cast<XmlNode>()
                    .Where(a => a.NextSibling.InnerText == artistName)
                    .Count();
                if (!artists.ContainsKey(artistName))
                {
                    artists.Add(artistName, numOfAlbums);
                }
            }

            foreach (var artist in artists)
            {
                Console.WriteLine("Artist: {0}; number of albums: {1}", artist.Key, artist.Value);
            }
        }
Example #15
0
 public static XImage FromFile(string filename)
 {
     XImage x = new XImage();
     try
     {
         XmlDocument doc = new XmlDocument();
         doc.Load(filename);
         XmlNodeList colorList = doc.SelectNodes("/Image/Point/Color");
         XmlNodeList xList = doc.SelectNodes("/Image/Point/X");
         XmlNodeList yList = doc.SelectNodes("/Image/Point/Y");
         
         for (int i = 0; i < xList.Count; i++)
         {
             IExtendFramework.Drawing.XPoint p = new IExtendFramework.Drawing.XPoint(
                 int.Parse(xList[i].InnerText),
                 int.Parse(yList[i].InnerText),
                 new Pen(Color.FromName(colorList[i].InnerText))
                );
             //MessageBox.Show(p.ToString());
             x.Points.Add(p);
         }
     }
     catch(Exception e)
     {
         throw e;
     }
     return x;
 }
Example #16
0
        public WebConfigImpl(FileInfo fileInfo)
        {
            Debug.Assert(null != fileInfo);
            if (!fileInfo.Exists) throw new InvalidDataException("fileInfo file does not exists.");

            string xsd = "http://chernoivanov.org/SmsDeliveryTest";
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(fileInfo.FullName);
            XmlNamespaceManager names = new XmlNamespaceManager(xDoc.NameTable);
            names.AddNamespace("a", xsd);

            XmlNode node = xDoc.SelectSingleNode("//a:DB", names);
            this.dbType = (DBType)Enum.Parse(typeof(DBType), node.Attributes["type"].Value, true);
            this.dbConnectionString = Utils.formatText(node.SelectSingleNode("a:ConnectionString/text()", names).Value).Replace("; ", ";");

            XmlNodeList nodes = xDoc.SelectNodes("//a:AudioFiles/*", names);

            if (0 == nodes.Count)
                throw new InvalidDataException("No nodes in AudioFiles");
            foreach (XmlNode n in xDoc.SelectNodes("//a:AudioFiles/*", names))
            {
                WebFileConfigImpl fileCfg = new WebFileConfigImpl(
                    n.Attributes["DirectoryForAudioFiles"].Value, 
                    n.Attributes["AudioFileExtension"].Value);
                senderConfigDictionary.Add(n.Attributes["MailSender"].Value, fileCfg);
            }
        }
Example #17
0
		/// <summary>
		/// Loads content project from file.
		/// </summary>
		/// <param name="fileName"></param>
		public ContentProject ( string fileName )
		{
			var text = File.ReadAllText( fileName );

			var doc = new XmlDocument();
			doc.LoadXml( text );

			contentDirs	=	doc
							.SelectNodes( "/ContentProject/ContentDirectories/Item")
							.Cast<XmlNode>()
							.Select( n => n.InnerText )
							.Distinct()
							.ToList();

			binaryDirs	=	doc
							.SelectNodes( "/ContentProject/BinaryDirectories/Item")
							.Cast<XmlNode>()
							.Select( n => n.InnerText )
							.Distinct()
							.ToList();

			assemblies	=	doc
							.SelectNodes( "/ContentProject/Assemblies/Item")
							.Cast<XmlNode>()
							.Select( n => n.InnerText )
							.Distinct()
							.ToList();

	
			assetsDesc	=	doc.SelectNodes( "/ContentProject/Asset")
							.Cast<XmlNode>()
							.Select( n => new AssetDesc( n ) )
							.ToList();
		}
Example #18
0
		protected virtual void Load (XmlDocument objects)
		{
			classes_by_cname.Clear ();
			classes_by_csname.Clear ();
			enums.Clear ();
			
			if (objects == null || objects.DocumentElement == null)
				return;
			
			targetGtkVersion = objects.DocumentElement.GetAttribute ("gtk-version");
			if (targetGtkVersion.Length == 0)
				targetGtkVersion = "2.4";
			
			foreach (XmlElement element in objects.SelectNodes ("/objects/enum")) {
				EnumDescriptor enm = new EnumDescriptor (element);
				enums[enm.Name] = enm;
			}

			foreach (XmlElement element in objects.SelectNodes ("/objects/object"))
				AddClass (LoadClassDescriptor (element));

			XmlNamespaceManager nsm = new XmlNamespaceManager (objects.NameTable);
			nsm.AddNamespace ("xsl", "http://www.w3.org/1999/XSL/Transform");
			
			XmlNodeList nodes = objects.SelectNodes ("/objects/object/glade-transform/import/xsl:*", nsm);
			importElems = new XmlElement [nodes.Count];
			for (int n=0; n<nodes.Count; n++)
				importElems [n] = (XmlElement) nodes[n];
				
			nodes = objects.SelectNodes ("/objects/object/glade-transform/export/xsl:*", nsm);
			exportElems = new XmlElement [nodes.Count];
			for (int n=0; n<nodes.Count; n++)
				exportElems [n] = (XmlElement) nodes[n];
		}
        static void Main()
        {
            var doc = new XmlDocument();
            doc.Load("../../../catalog.xml");

            Console.WriteLine("Loaded XML document:");

            var artistList = doc.SelectNodes("/albums/album/artist/@name");
            var albumsList = doc.SelectNodes("/albums/album");


            Dictionary<string, int> albumsPerArtist = new Dictionary<string, int>();

            foreach (XmlNode element in artistList)
            {
                albumsPerArtist.Add(element.Value, 0);

                foreach (XmlNode album in albumsList)
                {
                    if (album["artist"].Attributes["name"].Value == element.Value)
                    {
                        albumsPerArtist[element.Value]++;
                    }
                }
            }

            foreach (var entry in albumsPerArtist)
            {
                Console.WriteLine("Artist: {0}\nNumber Of Albums: {1}\n", entry.Key, entry.Value);
            }

        }
        //unused
        public static Project LoadProject(string FileName)
        {
            //load xml
            XmlDocument xdoc = new XmlDocument();
            xdoc.Load(FileName);

            //creat new project
            Project project = new Project();
            project.FileName = FileName;

            //folders
            XmlNodeList xnodes = xdoc.SelectNodes("project/folder");

            project.Folders = LoadFolders(xnodes);

            //build groups
            xnodes = xdoc.SelectNodes("project/buildgroup");

            project.BuildGroups = LoadBuildGroups(xnodes);

            //variables
            xnodes = xdoc.SelectNodes("project/variable");

            project.Variables = LoadVariables(xnodes);

            return project;
        }
Example #21
0
        public static bool OpenWrapEnabled(string filePath)
        {
            if (!SysFile.Exists(filePath))
                return false;
            var xmlDoc = new XmlDocument();
            var namespaceManager = new XmlNamespaceManager(xmlDoc.NameTable);
            namespaceManager.AddNamespace("msbuild", MSBUILD_NS);

            using (var projectFileStream = SysFile.OpenRead(filePath))
                xmlDoc.Load(projectFileStream);
            var isOpenWrap = (from node in xmlDoc.SelectNodes(@"//msbuild:Import", namespaceManager).OfType<XmlElement>()
                              let attr = node.GetAttribute("Project")
                              where attr != null && Regex.IsMatch(attr, @"OpenWrap\..*\.targets")
                              select node).Any();

            var isDisabled =
                    (
                            from node in xmlDoc.SelectNodes(@"//msbuild:OpenWrap-EnableVisualStudioIntegration", namespaceManager).OfType<XmlElement>()
                            let value = node.Value
                            where value != null && value.EqualsNoCase("false")
                            select node
                    ).Any();

            return isOpenWrap && !isDisabled;
        }
        // Accumulation format is now called Victory.
        private static void Upgrades0210()
        {
            var xml = new XmlDocument();
            if (Config.Settings.SeparateEventFiles)
            {
                var targetPath = Path.Combine(Program.BasePath, "Tournaments");
                if (!Directory.Exists(targetPath)) Directory.CreateDirectory(targetPath);
                var files = new List<string>(Directory.GetFiles(targetPath, "*.tournament.dat",
                    SearchOption.TopDirectoryOnly));
                files.AddRange(Directory.GetFiles(targetPath, "*.league.dat",
                    SearchOption.TopDirectoryOnly));
                foreach (string filename in files)
                {
                    xml.Load(filename);
                    var oldNodes = xml.SelectNodes("//Events/Tournaments/Tournament/Format[. = 'Accumulation']");
                    if (oldNodes != null)
                        foreach (XmlNode oldNode in oldNodes)
                            oldNode.InnerText = "Victory";
                    oldNodes = xml.SelectNodes("//Events/Leagues/League/Format[. = 'Accumulation']");
                    if (oldNodes != null)
                        foreach (XmlNode oldNode in oldNodes)
                            oldNode.InnerText = "Victory";

                    var writer = new XmlTextWriter(new FileStream(filename, FileMode.Create), null)
                        {
                            Formatting = Formatting.Indented,
                            Indentation = 1,
                            IndentChar = '\t'
                        };

                    xml.WriteTo(writer);
                    writer.Flush();
                    writer.Close();
                }
            }
            else if (File.Exists(Path.Combine(Program.BasePath, "Events.dat")))
            {
                xml.Load(Path.Combine(Program.BasePath, "Events.dat"));
                var oldNodes = xml.SelectNodes("//Events/Tournaments/Tournament/Format[. = 'Accumulation']");
                if (oldNodes != null)
                    foreach (XmlNode oldNode in oldNodes)
                        oldNode.InnerText = "Victory";
                oldNodes = xml.SelectNodes("//Events/Leagues/League/Format[. = 'Accumulation']");
                if (oldNodes != null)
                    foreach (XmlNode oldNode in oldNodes)
                        oldNode.InnerText = "Victory";

                var writer = new XmlTextWriter(new FileStream(Path.Combine(Program.BasePath,
                                                                           "Events.dat"), FileMode.Create), null)
                {
                    Formatting = Formatting.Indented,
                    Indentation = 1,
                    IndentChar = '\t'
                };

                xml.WriteTo(writer);
                writer.Flush();
                writer.Close();
            }
        }
Example #23
0
        static void Main(string[] args) {
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            if (args.Length < 3) {
                help();
                return;
            }
            String source_dir = args[1].Replace("\"", "");
            String target_dir = args[2].Replace("\"", "");

            XmlDocument xml_rules = new XmlDocument();
            xml_rules.Load(args[0]);

        //read list of languages that should be ignored or renamed
            Dictionary<String, String> langs = new Dictionary<String, String>();
            foreach (XmlNode node in xml_rules.SelectNodes("//lang")) {
                langs.Add( node.SelectSingleNode("@id").InnerText,  node.SelectSingleNode("@renameTo").InnerText);
            }

        //read list of rules and apply each rule
            foreach (XmlNode node in xml_rules.SelectNodes("//rule")) {
                Rule r = new Rule(node);
                StringBuilder sb = new StringBuilder();
                apply_rule(r, source_dir, target_dir, langs, sb);
                Console.WriteLine(sb.ToString());
            }
        }
Example #24
0
        static Rfc822DateTime()
        {
            XmlDocument xml = new XmlDocument();
            xml.Load("formats.xml");

            List<string> formatList = new List<string>();
            XmlNodeList formatNodes = xml.SelectNodes("/datetimeparser/formats/format");
            foreach (XmlNode formatNode in formatNodes)
            {
                formatList.Add(formatNode.InnerText);
            }
            // Fall back patterns
            formatList.Add(DateTimeFormatInfo.InvariantInfo.UniversalSortableDateTimePattern);
            formatList.Add(DateTimeFormatInfo.InvariantInfo.SortableDateTimePattern);
            formats = formatList.ToArray();

            timezoneOffsets = new Dictionary<string, string>();
            XmlNodeList timezoneNodes = xml.SelectNodes("/datetimeparser/timezones/timezone");
            foreach (XmlNode timezoneNode in timezoneNodes)
            {
                string abbr = timezoneNode.Attributes["abbr"].Value;
                string val = timezoneNode.InnerText;
                timezoneOffsets.Add(abbr, val);
            }
        }
Example #25
0
		public TestsCatalog(string catalogName, bool collectExluded)
		{
			if (catalogName == "")
			{
				catalogName = "test_catalog.xml";
			}

			try
			{
				_testsListXml = new XmlDocument();
				_testsListXml.Load(catalogName);
			}
			catch(Exception e)
			{
				throw e;
			}

			try
			{
				if (collectExluded)
					_tests = _testsListXml.SelectNodes("/TestCases/TestCase").GetEnumerator();
				else
					_tests = _testsListXml.SelectNodes("/TestCases/TestCase[@Exclude='N']").GetEnumerator();
			}
			catch(Exception e)
			{
				throw e;
			}
		}
        internal TextureFinder( string daeFile )
        {
            XmlDocument doc = new XmlDocument();

            m_DaeInfo = GetDaeFileInfo( daeFile );

            doc.Load( m_DaeInfo.FullName );

            #if XPATH_WORKS_THE_WAY_I_THINK
            XmlNodeList imageNodes = doc.SelectNodes( "//library_images/image" );

            foreach( XmlElement imageNode in imageNodes )
            {
                // ...evaluate the imageNode...
            }
            #else
            XmlNodeList libraryNodes = doc.SelectNodes( "*/*" );

            foreach( XmlElement libNode in libraryNodes )
            {
                if( libNode.Name.Equals( "library_images" ) )
                {
                    ParseNewStyleImageLibrary( libNode );
                }
                else if( libNode.Name.Equals( "library" ) &&
                         libNode.GetAttribute( "type" ).Equals( "IMAGE" ) )
                {
                    ParseOldStyleImageLibrary( libNode );
                }
            }
            #endif
        }
Example #27
0
        //Why does this not work?"
        public static void DoesNotWork_TestSelectWithDefaultNamespace()
        {
            // xml to parse with defaultnamespace
            string xml = @"<a xmlns='urn:test.Schema'><b/><b/></a>";

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

            // fails because xpath does not have the namespace
            //!!!!
            Debug.Assert(doc.SelectNodes("//b").Count == 2);


            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
            nsmgr.AddNamespace("", "urn:test.Schema");

            // This will fail. Why?
            //This is a FAQ.In XPath any unprefixed name is assumed to be in "no namespace".
            //In order to select elements that belong to a namespace, 
            //in any XPath expression their names must be prefixed with a prefix that is associated with this namespace.
            //The AddNamespace() method serves exactly this purpose.It creates a binding between a specific namespace and a specific prefix.
            //Then, if this prefix is used in an XPath expression, the element prefixed by it can be selected.

            //It is written in the XPath W3C spec: "A QName in the node test is expanded into an expanded-name using the namespace declarations from the expression context. 
            //This is the same way expansion is done for element type names in start and end-tags except that the default namespace declared with xmlns is not used: 
            //if the QName does not have a prefix, then the namespace URI is null".

            //See this at: w3.org/TR/xpath/#node-tests .

            //So, any unprefixed name is considered to be in "no namespace". 
            //In the provided XML document there are no b elements in "no namespace" and this is why the XPath expression //b selects no nodes at all.
            // using XPath defaultnamespace 
            //!!!!
            Debug.Assert(doc.SelectNodes("//b", nsmgr).Count == 2);
        }
        public void ApplyTransformation(ScoreDocument score, XmlDocument museScoreXmlFile)
        {
            if (!score.RemoveLabels)
              {
            return;
              }

              var shortNameNodes = museScoreXmlFile.SelectNodes("//shortName[subtype[text()='InstrumentShort']]/html-data");
              if (shortNameNodes == null)
              {
            return;
              }

              var longNameNodes = museScoreXmlFile.SelectNodes("//name[subtype[text()='InstrumentLong']]/html-data");
              if (longNameNodes == null)
              {
            return;
              }

              foreach (var shortNameNode in shortNameNodes)
              {
            ((XmlElement)shortNameNode).InnerXml = "";
              }

              foreach (var longNameNode in longNameNodes)
              {
            ((XmlElement)longNameNode).InnerXml = "";
              }
        }
Example #29
0
 private void LoadWebSiteConfig()
 {
     #region 装载日志信息
     XmlDocument doc = new XmlDocument();
     doc.Load(configPath);
     XmlNodeList postlistNode = doc.SelectNodes("/Aggregationinfo/Aggregationdata/" + pagename + "aggregationdata/" + pagename + "_spacearticlelist/Article");
     XmlNodeList index_spacelistnode = doc.SelectNodes("/Aggregationinfo/Aggregationpage/" + pagename + "/" + pagename + "_spacearticlelist/Article");
     XmlNodeInnerTextVisitor data_postvisitor = new XmlNodeInnerTextVisitor();
     XmlNodeInnerTextVisitor index_postvisitor = new XmlNodeInnerTextVisitor();
     postlist.Text = "";
     int i = 0;
     foreach (XmlNode post in postlistNode)
     {
         data_postvisitor.SetNode(post);
         bool isCheck = false;
         foreach (XmlNode index in index_spacelistnode)
         {
             index_postvisitor.SetNode(index);
             if (data_postvisitor["postid"].ToString() == index_postvisitor["postid"].ToString())
             {
                 isCheck = true;
                 break;
             }
         }
         postlist.Text += "<div class='mo' id='m" + i + "' flag='f" + i + "'><h1><input type='checkbox' name='pid' " + (isCheck ? "checked" : "") + " value='" + data_postvisitor["postid"] + "'>" + data_postvisitor["title"] + "</h1></div>\n";
         i++;
     }
     #endregion
 }
Example #30
0
        static Rfc822DateTime()
        {
            string folder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string file = System.IO.Path.Combine(folder, "formats.xml");

            XmlDocument xml = new XmlDocument();
            xml.Load(file);

            List<string> formatList = new List<string>();
            XmlNodeList formatNodes = xml.SelectNodes("/datetimeparser/formats/format");
            foreach (XmlNode formatNode in formatNodes)
            {
                formatList.Add(formatNode.InnerText);
            }
            // Fall back patterns
            formatList.Add(DateTimeFormatInfo.InvariantInfo.UniversalSortableDateTimePattern);
            formatList.Add(DateTimeFormatInfo.InvariantInfo.SortableDateTimePattern);
            formats = formatList.ToArray();

            timezoneOffsets = new Dictionary<string, string>();
            XmlNodeList timezoneNodes = xml.SelectNodes("/datetimeparser/timezones/timezone");
            foreach (XmlNode timezoneNode in timezoneNodes)
            {
                string abbr = timezoneNode.Attributes["abbr"].Value;
                string val = timezoneNode.InnerText;
                timezoneOffsets.Add(abbr, val);
            }
        }