コード例 #1
0
ファイル: Loader.cs プロジェクト: Aphramzo/AnAvalancheOfStats
    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;
            }
        }
    }
コード例 #2
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);
            }
        }
コード例 #3
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();
		}
コード例 #4
0
ファイル: XmlNameSpaceTest.cs プロジェクト: ittray/LocalDemo
        //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);
        }
コード例 #5
0
 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);
         }
     }
 }
コード例 #6
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;
 }
コード例 #7
0
        private List <string> GetFolders(BOAuthentication authModel)
        {
            XmlDocument   docRecv       = new System.Xml.XmlDocument();
            List <string> _lstfolderIds = new List <string>();

            _biRepository.CreateWebRequest(send: null, recv: docRecv, method: "GET", URI: authModel.URI, URIExtension: "/biprws/infostore/Root%20Folder/children",
                                           pLogonToken: authModel.LogonToken);

            XmlNamespaceManager nsmgrGET = new XmlNamespaceManager(docRecv.NameTable);

            nsmgrGET.AddNamespace("rest", authModel.NameSpace);

            ReportCategory category = new ReportCategory();
            XmlNodeList    nodeList = docRecv.SelectNodes("//rest:attr[@name='type']", nsmgrGET);

            for (int i = 0; i < nodeList.Count; i++)
            {
                if (nodeList.Item(i).InnerText == "Folder")
                {
                    category.Name        = docRecv.SelectNodes("//rest:attr[@name='name']", nsmgrGET)[i].InnerText;
                    category.InfoStoreId = docRecv.SelectNodes("//rest:attr[@name='id']", nsmgrGET)[i].InnerText;
                    category.Description = docRecv.SelectNodes("//rest:attr[@name='description']", nsmgrGET)[i].InnerText;
                    category.Cuid        = docRecv.SelectNodes("//rest:attr[@name='cuid']", nsmgrGET)[i].InnerText;
                    _lstfolderIds.Add(category.InfoStoreId);
                    //GetChildren(authModel, category);
                }
            }

            return(_lstfolderIds);
        }
コード例 #8
0
ファイル: TestExecuter.cs プロジェクト: RobBowman/BizUnit
		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;
		}
コード例 #9
0
 /// <summary>
 /// 循环验证input中所有属性与规则是否正确
 /// </summary>
 /// <param name="ProcessInfo"></param>
 /// <param name="xmlDoc"></param>
 /// <param name="inputAttrList"></param>
 /// <param name="obj"></param>
 public void InputAttrList(WorkflowProcessModule info, System.Xml.XmlDocument xmlDoc, List <Dictionary <string, object> > inputAttrList, CheckResult result)
 {
     foreach (Dictionary <string, object> inputAttr in inputAttrList)
     {
         int ItemI      = xmlDoc.SelectNodes("/BusinessType/Item/Domain[@name='" + inputAttr["dm_name_show_temp"].ToString() + "']").Count;
         int GroupItemI = xmlDoc.SelectNodes("/BusinessType/Item/Group/Item/Domain[@name='" + inputAttr["dm_name_show_temp"].ToString() + "']").Count;
         if (ItemI > 1 || GroupItemI > 1)
         {
             result.ErrorList.Add("DomainXml存在重复节点!");
         }
         //判定input中所有的值是否都在业务域中
         if (ItemI == 0 && GroupItemI == 0)
         {
             result.ErrorList.Add("dm_name_show_temp不在业务域中!");
         }
         else
         {
             //判定Input中是否存在规则中必须要存在的值
             Dictionary <string, string> dic = InputAttrRules(inputAttr, inputAttrList);
             if (dic == null || dic.Count == 0)
             {
                 return;
             }
             foreach (var item in dic)
             {
                 result.ErrorList.Add(item.Value);
             }
         }
     }
 }
コード例 #10
0
        /// <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;
        }
コード例 #11
0
ファイル: postaggset.aspx.cs プロジェクト: wenysky/dnt31-lite
 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
 }
コード例 #12
0
        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 = "******";
            }

            CustomMethods.webDriver = new FirefoxDriver();
        }
コード例 #13
0
ファイル: WidgetLibrary.cs プロジェクト: Kalnor/monodevelop
		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];
		}
コード例 #14
0
        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
        }
コード例 #15
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);
            }
        }
コード例 #16
0
		/// <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) {
				}
			}
		}
コード例 #17
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;
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: AluminumKen/hl2sb-src
        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);
        }
コード例 #19
0
        // 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();
            }
        }
コード例 #20
0
ファイル: XImage.cs プロジェクト: mlnlover11/IExtendFramework
 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;
 }
コード例 #21
0
        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);
            }

        }
コード例 #22
0
        private static Stream SaveDAPImage(System.Xml.XmlDocument hDoc, string strFile)
        {
            System.Xml.XmlNodeList hNodeList = hDoc.SelectNodes("/" + Geosoft.Dap.Xml.Common.Constant.Tag.GEO_XML_TAG + "/" + Geosoft.Dap.Xml.Common.Constant.Tag.RESPONSE_TAG + "/" + Geosoft.Dap.Xml.Common.Constant.Tag.IMAGE_TAG + "/" + Geosoft.Dap.Xml.Common.Constant.Tag.PICTURE_TAG);
            if (hNodeList.Count == 0)
            {
                hNodeList = hDoc.SelectNodes("/" + Geosoft.Dap.Xml.Common.Constant.Tag.GEO_XML_TAG + "/" + Geosoft.Dap.Xml.Common.Constant.Tag.RESPONSE_TAG + "/" + Geosoft.Dap.Xml.Common.Constant.Tag.TILE_TAG);
            }
            System.IO.FileStream   fs = new System.IO.FileStream(strFile, System.IO.FileMode.Create);
            System.IO.BinaryWriter bs = new System.IO.BinaryWriter(fs);

            foreach (System.Xml.XmlNode hNode in hNodeList)
            {
                System.Xml.XmlNode hN1       = hNode.FirstChild;
                string             jpegImage = hN1.Value;

                if (jpegImage != null)
                {
                    byte[] jpegRawImage = Convert.FromBase64String(jpegImage);

                    bs.Write(jpegRawImage);
                }
            }
            bs.Flush();
            bs.Close();
            fs.Close();
            return(fs);
        }
コード例 #23
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;
        }
コード例 #24
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);
            }
        }
コード例 #25
0
ファイル: TestsCatalog.cs プロジェクト: nobled/mono
		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;
			}
		}
コード例 #26
0
ファイル: Program.cs プロジェクト: d3ric3/derice
        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");
            }
        }
コード例 #27
0
ファイル: PingBack.cs プロジェクト: pengyancai/cs-util
 /// <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;
     }
 }
コード例 #28
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();
        }
コード例 #29
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);
            }
        }
コード例 #30
0
ファイル: Program.cs プロジェクト: bravesoftdz/dvsrc
        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());
            }
        }
コード例 #31
0
        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 = "";
              }
        }
コード例 #32
0
        //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;
        }
コード例 #33
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;
        }
コード例 #34
0
ファイル: TheTVDB.cs プロジェクト: AlexAkulov/simpleDLNA
        public static UpdateInfo UpdatesSince(long time)
        {
            UpdateInfo info = new UpdateInfo();
            var        url  = String.Format("http://thetvdb.com/api/Updates.php?type=all&time={0}", time);
            string     xmlStr;

            using (var wc = new System.Net.WebClient())
            {
                xmlStr = wc.DownloadString(url);
            }
            var xmlDoc = new System.Xml.XmlDocument();

            xmlDoc.LoadXml(xmlStr);

            var s = xmlDoc.SelectNodes("//Series").OfType <XmlNode>();

            info.Series = (from n in s
                           select System.Int32.Parse(n.InnerText)).ToArray();

            var e = xmlDoc.SelectNodes("//Episode").OfType <XmlNode>();

            info.Episodes = (from n in e
                             select System.Int32.Parse(n.InnerText)).ToArray();

            return(info);
        }
コード例 #35
0
    protected void FlightSearch_Click(object sender, EventArgs e)
    {
        string depart = FromText.Text;
        string arrive = ToText.Text;

        Session["PlaneResults"] = null;
        RomeApi += "&oName=" + depart + "&dName=" + arrive + "";
        System.Net.WebRequest wrGETURL;
        wrGETURL = System.Net.WebRequest.Create(RomeApi);
        System.IO.Stream objStream;
        objStream = wrGETURL.GetResponse().GetResponseStream();
        System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
        xmlDoc.Load(objStream);
        XmlNamespaceManager mgr = new XmlNamespaceManager(xmlDoc.NameTable);

        mgr.AddNamespace("ns", "http://www.rome2rio.com/api/1.2/xml");
        System.Xml.XmlNodeList flightnode  = xmlDoc.SelectNodes("//ns:SearchResponse/ns:Route[@name='Fly']/ns:FlightSegment/ns:FlightItinerary", mgr);
        System.Xml.XmlNodeList flighthop   = xmlDoc.SelectNodes("//ns:SearchResponse/ns:Route[@name='Fly']/ns:FlightSegment/ns:FlightItinerary/ns:FlightLeg/ns:FlightHop", mgr);
        System.Xml.XmlNodeList flightprice = xmlDoc.SelectNodes("//ns:SearchResponse/ns:Route[@name='Fly']/ns:FlightSegment/ns:FlightItinerary/ns:FlightLeg/ns:IndicativePrice", mgr);
        plane[] flights = new plane[flightnode.Count];
        int     j       = 0;

        foreach (XmlNode xn in flightnode)
        {
            double monies = (Convert.ToDouble(xn.FirstChild.FirstChild.Attributes[0].Value));
            ahop[] ahops  = new ahop[xn.FirstChild.ChildNodes.Count - 1];
            System.Xml.XmlNodeList hoplist = xn.FirstChild.ChildNodes;
            int k = 0;
            foreach (XmlNode xhop in hoplist)
            {
                if (xhop.Name.Equals("IndicativePrice"))
                {
                    continue;
                }
                string dterm    = xhop.Attributes[0].Value;
                string aterm    = xhop.Attributes[1].Value;
                string dtime    = xhop.Attributes[2].Value;
                string atime    = xhop.Attributes[3].Value;
                string airline  = xhop.Attributes[5].Value;
                string flightid = xhop.Attributes[5].Value + xhop.Attributes[7].Value;
                ahops[k] = new ahop(dterm, aterm, dtime, atime, airline, flightid);
                k++;
            }
            string departure     = ahops[0].departure;
            string departuretime = ahops[0].departuretime;
            string arrival       = ahops[ahops.Length - 1].arrival;
            string arrivaltime   = ahops[ahops.Length - 1].arrivaltime;
            flights[j] = new plane(departure, departuretime, arrival, arrivaltime, monies);
            j++;
        }
        Session.Add("PlaneResults", flights);
        RomeApi = "http://free.rome2rio.com/api/1.2/xml/Search?key=RNMpNhbV";
        GridView1.DataSource = (plane[])Session["PlaneResults"];
        GridView1.DataBind();
    }
コード例 #36
0
 public void loadFile(string fname)
 {
     // load the selected file
     if (System.IO.File.Exists(fname))
     {
         setXmlFileName(fname);
         _xml.Load(_filename);
         this._skipSelectionChanged = true;
         setXmlDataProvider(this.FieldGrid, fieldXPath);
         this._skipSelectionChanged = false;
         setDatasetUI();
         _datarows = _xml.SelectNodes("//Data/Row");
     }
 }
コード例 #37
0
        public void Upgrade(string projectPath, string userSettingsPath, ref System.Xml.XmlDocument projectDocument, ref System.Xml.XmlDocument userSettingsDocument, ref System.Xml.XmlNamespaceManager nsm)
        {
            //Add DataTypeReferencedTableMappingSchemaName to each Parameter.
            foreach (XmlAttribute node in projectDocument.SelectNodes("//*/@DataTypeReferencedTableMappingName", nsm))
            {
                XmlAttribute tableSchemaName = (XmlAttribute)node.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.Value), nsm);
                XmlAttribute dataTypeReferencedTableMappingSchemaName = projectDocument.CreateAttribute("DataTypeReferencedTableMappingSchemaName");

                dataTypeReferencedTableMappingSchemaName.Value = tableSchemaName.Value;

                node.OwnerElement.Attributes.Append(dataTypeReferencedTableMappingSchemaName);
            }

            //Add ParentTableMappingSchemaName and ReferencedTableMappingSchemaName to each Foreign Key Mapping.
            foreach (XmlElement node in projectDocument.SelectNodes("//P:ForeignKeyMapping", nsm))
            {
                XmlAttribute parentTableSchemaName            = (XmlAttribute)projectDocument.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.GetAttribute("ParentTableMappingName")), nsm);
                XmlAttribute referencedTableSchemaName        = (XmlAttribute)projectDocument.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.GetAttribute("ReferencedTableMappingName")), nsm);
                XmlAttribute parentTableMappingSchemaName     = projectDocument.CreateAttribute("ParentTableMappingSchemaName");
                XmlAttribute referencedTableMappingSchemaName = projectDocument.CreateAttribute("ReferencedTableMappingSchemaName");

                parentTableMappingSchemaName.Value     = parentTableSchemaName.Value;
                referencedTableMappingSchemaName.Value = referencedTableSchemaName.Value;

                node.Attributes.Append(parentTableMappingSchemaName);
                node.Attributes.Append(referencedTableMappingSchemaName);
            }

            //Add ReferencedTableMappingSchemaName to each Enumeration Mapping.
            //Rename ReferencedTableName to ReferencedTableMappingName for each Enumeration Mapping
            foreach (XmlAttribute node in projectDocument.SelectNodes("//P:EnumerationMapping/@ReferencedTableName", nsm))
            {
                XmlAttribute tableSchemaName        = (XmlAttribute)projectDocument.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.Value), nsm);
                XmlAttribute tableMappingSchemaName = projectDocument.CreateAttribute("ReferencedTableMappingSchemaName");
                XmlAttribute tableMappingName       = projectDocument.CreateAttribute("ReferencedTableMappingName");

                tableMappingSchemaName.Value = tableSchemaName.Value;
                tableMappingName.Value       = node.Value;

                node.OwnerElement.Attributes.Append(tableMappingSchemaName);
                node.OwnerElement.Attributes.Append(tableMappingName);
                node.OwnerElement.Attributes.Remove(node);
            }

            //Remove Template.Name attribute.
            foreach (XmlAttribute node in projectDocument.SelectNodes("//P:Template/@Name", nsm))
            {
                node.OwnerElement.Attributes.Remove(node);
            }
        }
コード例 #38
0
ファイル: wwi_func.cs プロジェクト: Publiship/WWI_CRM_folders
        /// <summary>
        /// get araylist of named element values from an xml file
        /// </summary>
        /// <param name="xmlfile">path to xml file</param>
        /// <param name="filter">row filter e.g. elementname ='value'</param>
        /// <param name="returnelement">name of element from which to return values</param>
        /// <returns></returns>
        public static IList <string> array_from_xml(string xmlfile, string nodepath)
        {
            IList <string> _results = new List <string>();

            try
            {
                string _path = AppDomain.CurrentDomain.BaseDirectory;
                _path += xmlfile;

                System.Xml.XmlDocument _xdoc = new System.Xml.XmlDocument();
                _xdoc.Load(_path);

                System.Xml.XmlNodeList _nodes = _xdoc.SelectNodes(nodepath);

                foreach (System.Xml.XmlNode _n in _nodes)
                {
                    string _text = _n.InnerText.ToString();
                    if (!string.IsNullOrEmpty(_text))
                    {
                        _results.Add(_text);
                    }
                }
            }
            catch (Exception ex)
            {
                _results.Add(ex.Message.ToString());
            }

            return(_results);
        }
コード例 #39
0
        public string GetOracleConnectString()
        {
            try
            {
                //用XmlTextReader类的对象来读取该XML文档
                // XmlTextReader xmlReader = new System.Xml.XmlTextReader(Application.StartupPath + "\\ConnectSetting.xml");
                XmlTextReader xmlReader = new System.Xml.XmlTextReader(AppDomain.CurrentDomain.BaseDirectory + "\\bin\\ConnectSetting.xml");
                //用XmlDocument类的对象来加载XML文档
                XmlDocument xmlDoc = new System.Xml.XmlDocument();
                //加载xmlReader
                xmlDoc.Load(xmlReader);
                //读取节点
                XmlNodeList xmlNodeList = xmlDoc.SelectNodes("数据库连接/Oracle数据库");
                //读取数据库配置串
                strOracleConnectString = xmlNodeList.Item(0).Attributes[0].Value;

                //strOracleConnectString = "data source=orcl;password=lis;persist security info=True;user id=yinbsh";
                //读取数据库类型
                strDbType = xmlNodeList.Item(0).Attributes[1].Value;
                //strDbType = "ORACLE";
                return(strOracleConnectString);
            }
            catch
            {
                HdisCommon.Log.Logging("{0}", "判断连接串是否正确!");

                return("");
            }
        }
コード例 #40
0
        public void showASpecPodcast(string rss, string xmlCate, string XmlUpdate)
        {
            System.Net.WebRequest  myRequest  = System.Net.WebRequest.Create(rss);
            System.Net.WebResponse myResponse = myRequest.GetResponse();

            System.IO.Stream       rssStream = myResponse.GetResponseStream();
            System.Xml.XmlDocument rssDoc    = new System.Xml.XmlDocument();

            rssDoc.Load(rssStream);
            rssStream.Close();
            System.Xml.XmlNode rssName = rssDoc.SelectSingleNode("rss/channel");
            var podcastName            = rssName.InnerText;

            System.Xml.XmlNodeList xx = rssDoc.SelectNodes("rss/channel/item");
            int antalEpisoder         = xx.Count;

            int.TryParse(XmlUpdate, out int XmlUpdateint);
            string frekvens = source.FirstOrDefault(x => x.Value == XmlUpdateint).Key;

            string[] RowPodCast = { antalEpisoder.ToString(), podcastName, frekvens, xmlCate, rss };
            var      listItem   = new ListViewItem(RowPodCast);

            lbEpisode.Items.Clear();
            lvPodcast.Items.Add(listItem);
        }
コード例 #41
0
        protected string[] GetWebConfigAssemblies(string webconfig)
        {
            List <string> list = new List <string>();

            string xpath_expr = @"//configuration/system.web/compilation/assemblies/add";

            FileInfo webConfigFile = new FileInfo(webconfig);

            if (!webConfigFile.Exists)
            {
                // return empty string array
                return(list.ToArray());
            }


            XmlDocument xmldoc = new System.Xml.XmlDocument();

            xmldoc.Load(webConfigFile.FullName);

            XmlNodeList valueList = xmldoc.SelectNodes(xpath_expr);

            foreach (System.Xml.XmlNode val in valueList)
            {
                string assembly = val.Attributes["assembly"].Value;

                if (!string.IsNullOrEmpty(assembly))
                {
                    list.Add(assembly);
                }
            }



            return(list.ToArray());
        }
コード例 #42
0
        //Inserts comma seperated string of PubMed Ids into the db
        private void InsertPubMedIds(string value)
        {
            string uri = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?retmax=1000&db=pubmed&retmode=xml&id=" + value;

            System.Xml.XmlDocument myXml = new System.Xml.XmlDocument();
            myXml.LoadXml(this.HttpPost(uri, "Catalyst", "text/plain"));
            XmlNodeList nodes = myXml.SelectNodes("PubmedArticleSet/PubmedArticle");

            Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();

            foreach (XmlNode node in nodes)
            {
                string pmid = node.SelectSingleNode("MedlineCitation/PMID").InnerText;

                if (!data.CheckPublicationExists(pmid))
                {
                    // Insert or update the publication
                    data.AddPublication(pmid, node.OuterXml);
                }

                // Assign the user to the publication
                data.AddPublication(_personId, _subject, Convert.ToInt32(pmid), this.PropertyListXML);
            }

            data.UpdateEntityOnePerson(_personId);
            this.KillCache();
            this.Counter = 0;
            Session["phAddPub.Visible"]           = null;
            Session["pnlAddPubMed.Visible"]       = null;
            Session["pnlAddCustomPubMed.Visible"] = null;
            Session["pnlDeletePubMed.Visible"]    = null;
            upnlEditSection.Update();
        }
コード例 #43
0
 /// <summary>
 /// 根据Xml设置DataSet显示
 /// </summary>
 private void ReadXmlSetData()
 {
     if (System.IO.File.Exists(this.filePath))
     {
         if (!this.doc.HasChildNodes)
         {
             this.InitXmlDoc();
         }
         XmlNodeList nodes = doc.SelectNodes("//Column");
         if (nodes == null)
         {
             MessageBox.Show("Xml文档格式不符合规范 请重新建立");
             return;
         }
         this.dt.Rows.Clear();
         foreach (XmlNode node in nodes)
         {
             this.dt.Rows.Add(new Object[] { node.Attributes["displayname"].Value,
                                             bool.Parse(node.Attributes["visible"].Value),
                                             bool.Parse(node.Attributes["sort"].Value),
                                             bool.Parse(node.Attributes["enable"].Value),
                                             false });
         }
     }
 }
コード例 #44
0
ファイル: ReadXml.cs プロジェクト: 364988343/SuperMes
        /// <summary>
        /// 读取某个文件某个路径下的某个属性值
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public string ReadAttrFromFile(string fileName, string path, string name)
        {
            string XMLFileName = System.AppDomain.CurrentDomain.BaseDirectory + @"config\" + fileName;

            try
            {
                XmlDocument xd = new System.Xml.XmlDocument();
                xd.Load(XMLFileName);

                foreach (XmlNode xn in xd.SelectNodes(path))
                {
                    if (name == "")
                    {
                        return("");
                    }
                    string attrName = NodeAtt(xn, name);
                    if (attrName != "")
                    {
                        return(attrName);
                    }
                }
                return(null);
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "读取!" + fileName + "出错" + exception.ToString());
            }
            return(null);
        }
コード例 #45
0
ファイル: EditMyProduct.cs プロジェクト: uvbs/eshopSanQiang
 private System.Collections.Generic.Dictionary <string, decimal> GetSkuPrices()
 {
     System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
     System.Collections.Generic.Dictionary <string, decimal> dictionary = null;
     System.Collections.Generic.Dictionary <string, decimal> result;
     try
     {
         xmlDocument.LoadXml(this.txtSkuPrice.Text);
         System.Xml.XmlNodeList xmlNodeList = xmlDocument.SelectNodes("//item");
         if (xmlNodeList != null && xmlNodeList.Count != 0)
         {
             System.Collections.Generic.IList <SKUItem> skus = SubSiteProducthelper.GetSkus(this.productId.ToString());
             dictionary = new System.Collections.Generic.Dictionary <string, decimal>();
             foreach (System.Xml.XmlNode xmlNode in xmlNodeList)
             {
                 string  value = xmlNode.Attributes["skuId"].Value;
                 decimal num   = decimal.Parse(xmlNode.Attributes["price"].Value);
                 foreach (SKUItem current in skus)
                 {
                     if (current.SkuId == value && current.SalePrice != num)
                     {
                         dictionary.Add(value, num);
                     }
                 }
             }
             return(dictionary);
         }
         result = null;
     }
     catch
     {
         return(dictionary);
     }
     return(result);
 }
コード例 #46
0
        public Feed CreateEntitiesFromSaveFile(string URL, string FeedName, string FeedURL, string FeedCategory, int FeedUpdateInterval)
        {
            Boolean FeedCreated = false;

            Feed NewFeed = new Feed();

            var XMLDocument = new System.Xml.XmlDocument();

            XMLDocument.Load(URL);

            XmlNodeList FeedDataNodeList = XMLDocument.SelectNodes("/feeds/feed/podcast");

            foreach (XmlNode Item in FeedDataNodeList)
            {
                if (!FeedCreated)
                {
                    NewFeed     = CreateFeed(FeedName, FeedCategory, FeedURL, FeedUpdateInterval);
                    FeedCreated = true;
                }

                string Title             = Item.SelectSingleNode("title").InnerText;
                string PlayURL           = Item.SelectSingleNode("playurl").InnerText;
                string PublishingDate    = Item.SelectSingleNode("publishingdate").InnerText;
                string StringListenCount = Item.SelectSingleNode("listencount").InnerText;

                int ListenCount = Int32.Parse(StringListenCount);

                Podcast NewPodcast = CreatePodcast(Title, PlayURL, PublishingDate, ListenCount);
                NewFeed.AddDataToList(NewPodcast);
            }
            return(NewFeed);
        }
コード例 #47
0
ファイル: Preferences.cs プロジェクト: teotikalki/tasque
        public List <string> GetStringList(string settingKey)
        {
            if (settingKey == null || settingKey.Trim() == string.Empty)
            {
                throw new ArgumentNullException("settingKey", "Preferences.GetStringList() called with a null/empty settingKey");
            }

            List <string> stringList = new List <string> ();

            // Select all nodes whose parent is the settingKey
            string      xPath = string.Format("//{0}/*", settingKey.Trim());
            XmlNodeList list  = document.SelectNodes(xPath);

            if (list == null)
            {
                return(stringList);
            }

            foreach (XmlNode node in list)
            {
                if (node.InnerText != null && node.InnerText.Length > 0)
                {
                    stringList.Add(node.InnerText);
                }
            }

            return(stringList);
        }
コード例 #48
0
        public void TakeCopies(PersonRegistration dbReg, out string contentsXml, out string sourceXml)
        {
            var oioReg = PersonRegistration.ToXmlType(dbReg);

            oioReg.AttributListe.Egenskab[0].FoedestedNavn = null;
            contentsXml = Strings.SerializeObject(oioReg);

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(contentsXml);
            var nsmgr = new XmlNamespaceManager(new NameTable());

            nsmgr.AddNamespace("ns", "urn:oio:sagdok:2.0.0");
            var nodes = doc.SelectNodes("//ns:Virkning", nsmgr);

            Console.WriteLine("Nodes : {0}", nodes.Count);
            foreach (XmlNode node in nodes)
            {
                node.ParentNode.RemoveChild(node);
            }

            contentsXml = doc.ChildNodes[1].OuterXml;
            // Repeat serialization to avoid empty text
            oioReg      = Strings.Deserialize <RegistreringType1>(contentsXml);
            contentsXml = Strings.SerializeObject(oioReg);

            sourceXml = dbReg.SourceObjects.ToString();
        }
コード例 #49
0
        public string getAddress(string username)
        {
            XmlDocument xdoc = new System.Xml.XmlDocument();

            // xdoc.Load(@"C:\Users\Pramod Kalidindi\Documents\Visual Studio 2013\Projects\Login\Login\obj\Debug\test.xml");
            //We find the path of the xml file and load it
            xdoc.Load(System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/Users1.xml"));


            //We go through every child node in user parent node to check if the user already signed up
            foreach (XmlNode node2 in xdoc.SelectNodes("//user"))
            {
                string uname = node2.SelectSingleNode("Username").InnerText;
                string pwd   = node2.SelectSingleNode("Password").InnerText;



                //  string uname = node2[0].InnerText;
                // string pwd = node3[0].InnerText;

                //If we find the username and and password we return a confirmation string
                if (username == uname)
                {
                    string address = node2.SelectSingleNode("Address").InnerText;
                    // string confirmation = "You are already signed up!";
                    return(address);
                }
            }

            // string confirmation1 = "The details you have entered are wrong. Type the correct details ";
            return("Address Not Found");
        }
コード例 #50
0
 protected System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > GetAttributes(string attributesXml)
 {
     System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
     System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > dictionary = null;
     try
     {
         xmlDocument.LoadXml(attributesXml);
         System.Xml.XmlNodeList xmlNodeList = xmlDocument.SelectNodes("//item");
         if (xmlNodeList == null || xmlNodeList.Count == 0)
         {
             return(null);
         }
         dictionary = new System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> >();
         foreach (System.Xml.XmlNode xmlNode in xmlNodeList)
         {
             int key = int.Parse(xmlNode.Attributes["attributeId"].Value);
             System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>();
             foreach (System.Xml.XmlNode xmlNode2 in xmlNode.ChildNodes)
             {
                 if (xmlNode2.Attributes["valueId"].Value != "")
                 {
                     list.Add(int.Parse(xmlNode2.Attributes["valueId"].Value));
                 }
             }
             if (list.Count > 0)
             {
                 dictionary.Add(key, list);
             }
         }
     }
     catch
     {
     }
     return(dictionary);
 }
コード例 #51
0
ファイル: BaseMsg.cs プロジェクト: Cathorlin/yimao
 public static string getMsg(string msg_id)
 {
     try
     {
         System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
         string filename            = HttpRuntime.AppDomainAppPath + "\\" + GlobeAtt.LANGUAGE_ID + "Msg.xml";
         doc.Load(filename);
         XmlNodeList rowsNode = doc.SelectNodes("/MSG/" + msg_id);
         int         i        = 0;
         string      msg_     = "";
         if (rowsNode != null)
         {
             foreach (XmlNode rowNode in rowsNode)
             {
                 msg_ = rowNode.InnerXml;
                 break;
             }
         }
         // string data_ = "";
         //  XmlNodeList rowsNode = doc.SelectNodes("/DATA/ROW");
         return(msg_);
     }
     catch
     {
         return("");
     }
 }
コード例 #52
0
        private List <PeopleDirectoryUser> Read(System.Xml.XmlDocument xmlDoc)
        {
            List <PeopleDirectoryUser> aadusers = new List <PeopleDirectoryUser>();

            try
            {
                List <KeyValuePair <string, string> > properties = null;

                foreach (System.Xml.XmlElement userNode in xmlDoc.SelectNodes("//User"))
                {
                    properties = new List <KeyValuePair <string, string> >();

                    foreach (System.Xml.XmlAttribute userPropAttribute in userNode.Attributes)
                    {
                        properties.Add(new KeyValuePair <string, string>(userPropAttribute.Name, userPropAttribute.Value));
                    }

                    aadusers.Add(new PeopleDirectoryUser(properties.ToArray()));
                }
            }
            catch (Exception ex)
            {
                aadusers.Clear();
                //TraceEvents.Log.Error(string.Format("Error detail: {0}", ex.InnerException.Message));
            }

            return(aadusers);
        }
コード例 #53
0
        private void btnInstall_Click(object sender, EventArgs e)
        {
            KillRainfallProcess();
            //string version = getPrivateProfileString("基本信息","软件版本","0",
            StringBuilder temp = new StringBuilder(255);
            int           i    = GetPrivateProfileString("基本信息", "软件版本", "", temp, 255, szPath);

            CopyDirectory(this.source, this.destination);
            //writePrivateProfileString("Update", "isHaveNewVersion", "0", szPath);

            XmlDocument doc = new System.Xml.XmlDocument();

            doc.Load(AppDomain.CurrentDomain.BaseDirectory + "Update.xml");
            XmlNodeList pList = doc.SelectNodes("/update/valueList/item");

            try
            {
                foreach (XmlNode nl in pList)
                {
                    writePrivateProfileString("基本信息", nl.Attributes[0].Value, nl.Attributes[1].Value, szPath);
                }
            }
            catch
            {
            }
            string strNewBuildTime = ReadNewBuildTime(Application.StartupPath + "\\Update.xml", "/update/build ", "time");

            writePrivateProfileString("基本信息", "GMT", strNewBuildTime, szPath);
            writePrivateProfileString("基本信息", "更新时间", DateTime.Now.ToString(), szPath);
            CSQLite.G_CSQLite.WriteRunLogInfoDB("0xEF", "更新完成", temp.ToString());
            this.Close();
        }
コード例 #54
0
        private void PlatformPrivilegeListCreator()
        {
            if (System.IO.File.Exists(privilegePath) == false)
            {
                return;
            }

            try
            {
                var doc = new System.Xml.XmlDocument();
                doc.Load(privilegePath);

                var nodes = doc.SelectNodes("properties/entry");
                var arr   = nodes.OfType <XmlNode>().ToArray();
                PrivilegeItems.Clear();

                foreach (var arrItem in arr)
                {
                    PrivilegeSupporters newItem = new PrivilegeSupporters();
                    newItem.privilegeName = arrItem.Attributes["key"].Value;
                    newItem.privilegeDesc = arrItem.Attributes["desc"].Value;
                    PrivilegeItems.Add(newItem);
                }
            }
            catch
            {
            }
        }
コード例 #55
0
        //public bool SameCustomField(string customKey, System.Guid customFieldID)
        //{
        //    if (m_customFieldsByGUID.ContainsKey(customFieldID.ToString()))
        //    {
        //        if (m_customFieldsByGUID[customFieldID.ToString()] == customKey)
        //            return true;
        //    }
        //    return false;
        //}

        /// <summary>
        /// read the passed in path and file and pull out the classes and fields
        /// </summary>
        /// <param name="xmlFileName"></param>
        /// <returns>true if successfull</returns>
        public bool ReadLexImportFields(string xmlFileName)
        {
            bool success = true;

            System.Xml.XmlDocument xmlMap = new System.Xml.XmlDocument();
            try
            {
                xmlMap.Load(xmlFileName);
                System.Xml.XmlNode abbrSignatures = xmlMap.SelectSingleNode("ImportFields/AbbreviationSignatures");
                ReadSignatureNode(abbrSignatures);

                System.Xml.XmlNodeList classList = xmlMap.SelectNodes("ImportFields/Class");
                foreach (System.Xml.XmlNode classNode in classList)
                {
                    if (!ReadAClassNode(classNode))
                    {
                        success = false;
                    }
                }
                success = Initialize();

                // 6/2/08  Now add in any custom fields that are currently defined in the database
            }
            catch (System.Xml.XmlException)
            {
//				string ErrMsg = "Error: invalid mapping file '" + xmlFileName + "' : " + e.Message;
                success = false;
            }
            return(success);
        }
コード例 #56
0
        protected override void ExecuteTask()
        {
            if (srcurl.EndsWith("/") == false)
            {
                srcurl += "/";
            }

            if (destdir.EndsWith("\\") == false)
            {
                destdir += "\\";
            }


            if (oldrev == "0")
            {
                NoshellProcess.Execute("svn", string.Format("export --force -r {0} {1} {2}", newrev, srcurl, destdir));
            }
            else
            {
                System.Xml.XmlDocument xml = NoshellProcess.ExcuteXML("svn",
                                                                      string.Format("diff -r {0}:{1} --summarize --xml {2}", oldrev, newrev, srcurl));

                System.Xml.XmlNodeList nodes = xml.SelectNodes("/diff/paths/path");

                for (int i = 0; i < nodes.Count; i++)
                {
                    XmlNode node = nodes.Item(i);

                    string kind  = node.Attributes["kind"].Value;
                    string props = node.Attributes["props"].Value;
                    string item  = node.Attributes["item"].Value;
                    string path  = node.InnerXml.Replace(srcurl, "").Replace("/", "\\");

                    if (item == "none" && props != "none")
                    {
                        item = props;
                    }

                    if (kind == "file")
                    {
                        string destfilename = System.IO.Path.Combine(destdir, path);

                        if (System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(destfilename)) == false)
                        {
                            System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(destfilename));
                        }

                        System.Console.WriteLine(string.Format("Export {0}", path));
                        NoshellProcess.Execute("svn", string.Format("export --force -r {0} {1} {2}", newrev, node.InnerXml, destfilename));
                    }
                }
            }

            // 마지막으로 익스포트 된 파일을 전부 소문자로 변환한다.
            // 안하면 문제의 여지가 있다
            ConvertLowerCase(destdir);

            AddPatchInfo(System.IO.Path.Combine(destdir, "patchinfo.xml"), "PatcherFiles", patcherfiles);
            AddPatchInfo(System.IO.Path.Combine(destdir, "patchinfo.xml"), "VerifyFiles", verifyfiles);
        }
コード例 #57
0
        public static bool VisibleZaak(string ZaakTypeCode)
        {
            var config = new System.Xml.XmlDocument();

            config.Load("mapping.xml");

            var zaaktypes = config.SelectNodes("//zaaktype");

            foreach (System.Xml.XmlNode zt in zaaktypes)
            {
                if (zt.Attributes["matchfield"] == null && zt.Attributes["matchvalue"] == null)
                {
                    // catch-all
                    return(true);
                }
                if (zt.Attributes["matchfield"] != null && zt.Attributes["matchvalue"] != null)
                {
                    if (zt.Attributes["matchfield"].Value == "code" && zt.Attributes["matchvalue"].Value == ZaakTypeCode)
                    {
                        // de code is gevonden
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #58
0
        public void DocidCheck()
        {
            XmlDocument doc = new System.Xml.XmlDocument();

            doc.LoadXml(XmlConsts.CheckDocidXml);

            //c# MemberSignature is the same,but docid not
            var listA = doc.SelectNodes("/Type/Members/Member[@MemberName='op_Implicit']");

            if (listA.Count == 2)
            {
                var Notequal = DocUtils.DocIdCheck(listA[0], (XmlElement)listA[1]);
                Assert.IsTrue(Notequal);
            }

            //note:c not have docid item in xml
            var b = doc.SelectSingleNode("/Type/Members/Member[@MemberName='op_Implicit']");
            var c = doc.SelectSingleNode("/Type/Members/Member[@MemberName='.ctor']");

            var flg1 = DocUtils.DocIdCheck(b, (XmlElement)c);

            Assert.IsFalse(flg1);

            //Parameter change position
            var flg2 = DocUtils.DocIdCheck(c, (XmlElement)b);

            Assert.IsFalse(flg2);

            // c# MemberSignature is not same,docid also
            var d    = doc.SelectSingleNode("/Type/Members/Member[@MemberName='Value']");
            var flg3 = DocUtils.DocIdCheck(b, (XmlElement)d);

            Assert.IsTrue(flg3);
        }
コード例 #59
0
        private async void mediaTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            var lCurrentSubType = (string)streamComboBox.SelectedItem;

            var lCurrentSourceNode = mSelectedSourceXmlNode as XmlNode;

            if (lCurrentSourceNode == null)
            {
                return;
            }

            var lMediaTypesNode = lCurrentSourceNode.SelectNodes("PresentationDescriptor/StreamDescriptor/MediaTypes/MediaType[MediaTypeItem[@Name='MF_MT_SUBTYPE']/SingleValue[@Value='MFVideoFormat_" + lCurrentSubType + "']]");

            if (lMediaTypesNode == null)
            {
                return;
            }

            var lStreamNode = lCurrentSourceNode.SelectSingleNode("PresentationDescriptor/StreamDescriptor");

            if (lStreamNode == null)
            {
                return;
            }

            var lValueNode = lStreamNode.SelectSingleNode("@MajorTypeGUID");

            string lXPath = "EncoderFactories/Group[@GUID='blank']/EncoderFactory";

            lXPath = lXPath.Replace("blank", lValueNode.Value);


            string lxmldoc = await mCaptureManager.getCollectionOfEncodersAsync();

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            doc.LoadXml(lxmldoc);

            var lEncoderNodes = doc.SelectNodes(lXPath);

            encoderComboBox.Items.Clear();

            foreach (var item in lEncoderNodes)
            {
                var lNode = (XmlNode)item;

                if (lNode != null)
                {
                    var lvalueNode = lNode.SelectSingleNode("@Title");

                    ContainerItem lSourceItem = new ContainerItem()
                    {
                        mFriendlyName = lvalueNode.Value,
                        mXmlNode      = lNode
                    };

                    encoderComboBox.Items.Add(lSourceItem);
                }
            }
        }
コード例 #60
0
        public void loadPodCast(string url)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load("Feeds.xml");

            System.Xml.XmlNodeList rssItems = doc.SelectNodes("ArrayOfRssFeed/RssFeed");
            foreach (XmlNode RssFeed in rssItems)
            {
                var UrlRss = RssFeed.SelectSingleNode("Url").InnerText;

                int.TryParse(RssFeed.SelectSingleNode("Updating").InnerText, out int UpdatingRss);
                var CateRss = RssFeed.SelectSingleNode("Category").InnerText;
                System.Net.WebRequest  myRequest  = System.Net.WebRequest.Create(UrlRss);
                System.Net.WebResponse myResponse = myRequest.GetResponse();
                System.IO.Stream       rssStream  = myResponse.GetResponseStream();
                System.Xml.XmlDocument rssDoc     = new System.Xml.XmlDocument();
                rssDoc.Load(rssStream);
                rssStream.Close();
                System.Xml.XmlNode rssName = rssDoc.SelectSingleNode("rss/channel");
                var podcastName            = rssName.InnerText;
                System.Xml.XmlNodeList xx  = rssDoc.SelectNodes("rss/channel/item");
                int antalEpisoder          = xx.Count;

                string   frekvens   = source.FirstOrDefault(x => x.Value == UpdatingRss).Key;
                string[] RowPodCast = { antalEpisoder.ToString(), podcastName, frekvens, CateRss, UrlRss };
                var      listItem   = new ListViewItem(RowPodCast);

                lvPodcast.Items.Add(listItem);
            }
        }