當前位置: 首頁>>代碼示例>>C#>>正文


C# SgmlReader.MoveToNextAttribute方法代碼示例

本文整理匯總了C#中Sgml.SgmlReader.MoveToNextAttribute方法的典型用法代碼示例。如果您正苦於以下問題:C# SgmlReader.MoveToNextAttribute方法的具體用法?C# SgmlReader.MoveToNextAttribute怎麽用?C# SgmlReader.MoveToNextAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sgml.SgmlReader的用法示例。


在下文中一共展示了SgmlReader.MoveToNextAttribute方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FindImgs

        internal static ImageInfo[] FindImgs(
            string htmlCode)
        {
            var r =
                new SgmlReader
                    {
                        DocType = @"HTML",
                        InputStream = new StringReader(htmlCode)
                    };
            var al = new List<ImageInfo>();

            //find <img src=""
            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Element)
                {
                    if (string.Compare(r.Name, @"img", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if (r.HasAttributes)
                        {
                            var ii = new ImageInfo();

                            while (r.MoveToNextAttribute())
                            {
                                switch (r.Name.ToLowerInvariant())
                                {
                                    case @"src":
                                        ii.Source = r.Value;
                                        break;
                                    case @"width":
                                        ii.Width = ConvertHelper.ToInt32(r.Value);
                                        break;
                                    case @"height":
                                        ii.Height = ConvertHelper.ToInt32(r.Value);
                                        break;
                                }
                            }

                            // --

                            if (!string.IsNullOrEmpty(ii.Source))
                            {
                                al.Add(ii);
                            }
                        }
                    }
                }
            }

            return al.ToArray();
        }
開發者ID:jorik041,項目名稱:ZetaHtmlEditControl,代碼行數:51,代碼來源:HtmlConversionHelper.cs

示例2: Test_MoveToNextAttribute

        public void Test_MoveToNextAttribute()
        {

            // Make sure we can do MoveToElement after reading multiple attributes.
            var r = new SgmlReader {
                InputStream = new StringReader("<test id='10' x='20'><a/><!--comment-->test</test>")
            };
            Assert.IsTrue(r.Read());
            while(r.MoveToNextAttribute()) {
                _log.Debug(r.Name);
            }
            if(r.MoveToElement()) {
                _log.Debug(r.ReadInnerXml());
            }
        }
開發者ID:VitaliyBoris,項目名稱:SGMLReader,代碼行數:15,代碼來源:Tests.cs

示例3: RegressionTest1

 void RegressionTest1()
 {
     // Make sure we can do MoveToElement after reading multiple attributes.
     SgmlReader r = new SgmlReader();
     r.InputStream = new StringReader("<test id='10' x='20'><a/><!--comment-->test</test>");
     if (r.Read()) {
         while (r.MoveToNextAttribute()) {
             Trace.WriteLine(r.Name);
         }
         if (r.MoveToElement()) {
             Trace.WriteLine(r.ReadInnerXml());
         }
     }
 }
開發者ID:panuganti,項目名稱:nreadability,代碼行數:14,代碼來源:Test.cs

示例4: dsiTagReplacement

		public string dsiTagReplacement(Match m)
		{
			string tagName = "dsi";
			try
			{
				//string[] arrParts = m.Groups[1].Value.Split[" "];
				//Dictionary<string, string> parts = new Dictionary<string, string>();
				SgmlReader sgml = new SgmlReader();
				string inStr = m.Groups[0].Value;
				if (inStr.StartsWith("<dsi:link"))
					inStr += "</dsi:link>";
				sgml.InputStream = new StringReader(inStr);
				sgml.DocType = "HTML";
				sgml.Read();

				tagName = sgml.Name;
				string uniqueId = Guid.NewGuid().ToString("N");

				#region Parse attributes
				Dictionary<string, string> attributes = new Dictionary<string, string>();
				while (sgml.MoveToNextAttribute())
				{
					attributes.Add(sgml.Name.ToLower(), sgml.Value);
				}
				#endregion

				string typeAtt = attributes.ContainsKey("type") ? attributes["type"] : null;
				string refAtt = attributes.ContainsKey("ref") ? attributes["ref"] : null;

				#region Parse styles
				Dictionary<string, string> style = new Dictionary<string, string>();
				if (attributes.ContainsKey("style"))
				{
					foreach (string s in attributes["style"].Split(';'))
					{
						try
						{
							if (s.Contains(":"))
								style[s.Split(':')[0].Trim()] = s.Split(':')[1].Trim();
						}
						catch
						{
						}
					}
				}
				#endregion

				#region Parse class
				List<string> classes = new List<string>();
				if (attributes.ContainsKey("class"))
				{
					foreach (string s in attributes["class"].Split(' '))
					{
						try
						{
							classes.Add(s);
						}
						catch
						{
						}
					}
				}
				#endregion

				if (tagName == "dsi:video")
				{
					#region dsi:video
					/*
					<dsi:video 
						type = [dsi | flv | youtube | google | metacafe | myspace | break | collegehumor | redtube | ebaumsworld | dailymotion] 
						ref = [dsi-photo-k | site-ref]
						src = [flv-url]
						width = [width] (optional)
						height = [height] (optional)
						nsfw = [true | false] (optional)
						/> 
					*/
					bool nsfw = attributes.ContainsKey("nsfw") ? bool.Parse(attributes["nsfw"].ToLower()) : false;
					string draw = attributes.ContainsKey("draw") ? attributes["draw"].ToLower() : "auto";
					if (typeAtt == "youtube")
					{
						#region youtube
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 425;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 355;

						//<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/8VtWo8tFdPQ&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/8VtWo8tFdPQ&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.youtube.com/v/" + refAtt + "&rel=1");
						#endregion
					}
					else if (typeAtt == "metacafe")
					{
						#region metacafe
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 400;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 345;

						//<embed src="http://www.metacafe.com/fplayer/1029494/how_to_make_fire_balls.swf" width="400" height="345" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"> </embed><br><font size = 1><a href="http://www.metacafe.com/watch/1029494/how_to_make_fire_balls/">How To Make Fire Balls</a> - <a href="http://www.metacafe.com/">The funniest videos clips are here</a></font>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.metacafe.com/fplayer/" + refAtt + ".swf");
						#endregion
					}
					else if (typeAtt == "google")
//.........這裏部分代碼省略.........
開發者ID:davelondon,項目名稱:dontstayin,代碼行數:101,代碼來源:HtmlRenderer.cs


注:本文中的Sgml.SgmlReader.MoveToNextAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。