当前位置: 首页>>代码示例>>C#>>正文


C# SgmlReader.ReadOuterXml方法代码示例

本文整理汇总了C#中Sgml.SgmlReader.ReadOuterXml方法的典型用法代码示例。如果您正苦于以下问题:C# SgmlReader.ReadOuterXml方法的具体用法?C# SgmlReader.ReadOuterXml怎么用?C# SgmlReader.ReadOuterXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sgml.SgmlReader的用法示例。


在下文中一共展示了SgmlReader.ReadOuterXml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetXmlFromHtmlString

 public static String GetXmlFromHtmlString (String html)
 {
     using (SgmlReader sr = new SgmlReader())
     {
         sr.InputStream = new StringReader(html);
         return sr.ReadOuterXml();
     }
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:8,代码来源:HttpSgmlToXml.cs

示例2: getXmlReader

        //private static Value getDocXml (String uri, String path, HttpContext context)
        //{
        //    try
        //    {
        //        return Value.asValue(getXdmNode(uri, path, context).Unwrap());
        //    }
        //    catch (Exception e)
        //    {
        //        throw;
        //    }
        //}

        private static String getXmlReader (String uri, String path, HttpContext context)
        {
            string decodedUri = HttpUtility.UrlDecode(uri);
            string eTag = Context.GenerateETag(decodedUri, Nuxleus.Cryptography.HashAlgorithm.SHA1);
            String xhtml = String.Empty;

            try
            {

                if (m_CacheDictionary.ContainsKey(eTag))
                {
                    xhtml = m_CacheDictionary[eTag];
                }
                else
                {
                    using (SgmlReader sr = new SgmlReader())
                    {
                        try
                        {
                            if ((bool)context.Application["usememcached"])
                            {
                                MemcachedClient m_client = (MemcachedClient)context.Application["memcached"];

                                if (m_client.KeyExists(eTag))
                                {
                                    sr.InputStream = GetStreamFromHtmlString((string)m_client.Get(eTag));
                                }

                                else
                                {
                                    sr.Href = decodedUri;
                                    m_client.Add(eTag, sr.ReadOuterXml(), DateTime.Now.AddMinutes(60));
                                }

                            }
                            else
                            {
                                sr.Href = decodedUri;

                            }

                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                            Console.WriteLine(e.StackTrace);
                        }

                        xhtml = sr.ReadOuterXml();
                        m_CacheDictionary.Add(eTag, xhtml);

                    }
                }

                return xhtml;
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);

            }

            return String.Format(@"<html xmlns='http://www.w3.org/1999/xhtml'>
                                   <head>
                                    <title>No Readable HTML</title>
                                   </head>
                                   <body>
                                    <h1>No readable HTML was located at the specified URL</h1>
                                   </body>
                                 </html>");
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:85,代码来源:HttpSgmlToXml.cs

示例3: GetXmlFromHtmlString

 public static XNode GetXmlFromHtmlString(String html)
 {
     using (SgmlReader sr = new SgmlReader())
     {
         string htmlWrapper = String.Format("<div xmlns=\"http://www.w3.org/1999/xhtml\">{0}</div>", html);
         try
         {
             sr.InputStream = new StringReader(htmlWrapper);
             return XElement.Parse(sr.ReadOuterXml(), LoadOptions.None);
         }
         catch
         {
             return new XText(HttpUtility.HtmlEncode(html));
         }
     }
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:16,代码来源:NuxleusHttpAccountManagementServiceOperationHandler.cs


注:本文中的Sgml.SgmlReader.ReadOuterXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。