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


C# XDocument.ToXmlDocument方法代码示例

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


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

示例1: GetCraigslistJobDetails

 public XmlNode GetCraigslistJobDetails( XPathNodeIterator input )
 {
     input.MoveNext();
       var body = input.Current.OuterXml;
       var resultDocument = new XDocument();
       var resultElement = body.GetDetails();
       resultDocument.Add( resultElement );
       var result = resultDocument.ToXmlDocument().FirstChild;
       return result;
 }
开发者ID:cmcginn,项目名称:Marketing,代码行数:10,代码来源:XsltExtensions.cs

示例2: CheckXml

        /// <summary>
        /// Check an XElement against some expected XML.
        /// <para>
        /// The supplied node is copied and normalized to get actual differences.
        /// </para>
        /// </summary>
        /// <param name="expected">XElement to use</param>
        /// <param name="candidate">XML to compare against.</param>
        /// <param name="fullComparison">Whether to do a full comparison using prefix/namespace</param>
        /// <param name="diffFilePath">Where/whether to write out the HTML difference</param>
        public static string CheckXml(this XElement expected, XElement candidate, bool fullComparison = true, string diffFilePath = "")
        {
            // Xml's are normalized before comparision, so that we can get actual difference when we turn on Namespaces & Prefix's differnces
            var source = new XDocument(expected);
            source = source.Normalize();
            var expectedNode = source.ToXmlDocument().SelectSingleNode("/*");

            var target = new XDocument(candidate);
            target = target.Normalize();
            var candidateNode = target.ToXmlDocument().SelectSingleNode("/*");

            using (var stringWriter = new StringWriter())
            {
                bool areDifferent;
                using (var xmlWriter = new XmlTextWriter(stringWriter) { Formatting = Formatting.Indented })
                {
                    // Default engine ignores prefix/namespace so we need to enable if we are doing a full comparison.
                    var diff = DefaultDiffEngine();
                    diff.IgnorePrefixes = !fullComparison;
                    diff.IgnoreNamespaces = !fullComparison;
                    areDifferent = !diff.Compare(expectedNode, candidateNode, xmlWriter);
                }

                if (areDifferent)
                {
                    if (!string.IsNullOrEmpty(diffFilePath))
                    {
                        var diffgram = stringWriter.GetStringBuilder().ToString();
                        WriteDiffFile(diffFilePath, diffgram, expectedNode);
                    }
                    return string.Format(
                            "Xml differs.{0}Expected:{0}{1}{0}{0}Actual:{0}{2}{0}{0}Diff:{0}{3}",
                            Environment.NewLine,
                            expectedNode.ToXmlString(),
                            candidateNode.ToXmlString(),
                            stringWriter);
                }
            }

            return string.Empty;
        }
开发者ID:RustyF,项目名称:EnergyTrading-Core,代码行数:51,代码来源:XmlDiffFactory.cs

示例3: Rsd

        public HttpResponseMessage Rsd()
        {
            XNamespace ns = XNamespace.Get("http://archipelago.phrasewise.com/rsd");
            XDocument response = new XDocument(
                new XElement(ns + "service",
                    new XElement(ns + "engineName", "Dexter Blog Engine"),
                    new XElement(ns + "engineLink", "http://www.dexterblogengine.com"),
                    new XElement(ns + "homePageLink", this.urlBuilder.Home),
                    new XElement(ns + "apis",
                        new XElement(ns + "api",
                            new XAttribute("name", "MetaWeblog"),
                            new XAttribute("preferred", "true"),
                            new XAttribute("blogID", "0"),
                            new XAttribute("apiLink", this.urlBuilder.Service.MetaWebLogApi())))));

            return new HttpResponseMessage
                       {
                           Content = new XmlContent(response.ToXmlDocument())
                       };
        }
开发者ID:prabhakara,项目名称:Dexter-Blog-Engine,代码行数:20,代码来源:SyndicationController.cs


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