WriteSubtree() public method

public WriteSubtree ( XmlWriter writer ) : void
writer XmlWriter
return void
Ejemplo n.º 1
0
        private static XmlWriter CreateAssemblyWriter(string path, XPathNavigator assembly)
        {
            XmlWriterSettings settings = new XmlWriterSettings { Indent = true };
            XmlWriter writer = XmlWriter.Create(path, settings);

            writer.WriteStartElement("reflection");

            if(assembly != null)
            {
                writer.WriteStartElement("assemblies");
                assembly.WriteSubtree(writer);
                writer.WriteEndElement();
            }

            writer.WriteStartElement("apis");

            return writer;
        }
Ejemplo n.º 2
0
        private void ProcessXPathNavigator(XPathNavigator xpathNavigator)
        {
            try
            {
                using (StringWriter stringWriter = new StringWriter())
                {
                    using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, XmlWriterSettings))
                    {
                        xpathNavigator.WriteSubtree(xmlWriter);
                    }

                    WriteObject(stringWriter.ToString());
                }
            }
            catch (PipelineStoppedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                ErrorHandler.WriteXmlError(ex);
            }
        }
Ejemplo n.º 3
0
		string WriteSubtree (XPathNavigator nav)
		{
			StringWriter sw = new StringWriter ();
			XmlWriterSettings settings = new XmlWriterSettings ();
			settings.OmitXmlDeclaration = true;
			settings.ConformanceLevel = ConformanceLevel.Fragment;
			using (XmlWriter w = XmlWriter.Create (sw, settings)) {
				nav.WriteSubtree(w);
			}
			return sw.ToString ();
		}
		// I avoided OuterXml which includes indentation.
		string XPathNavigatorToString (XPathNavigator nav)
		{
			var sw = new StringWriter ();
			using (var xw = XmlWriter.Create (sw, xml_writer_settings))
				nav.WriteSubtree (xw);
			return sw.ToString ();
		}
Ejemplo n.º 5
0
        private void SaveCacheFile(XPathNavigator nav)
        {
            if (String.IsNullOrEmpty(cacheFile))
                return;

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.NewLineHandling = NewLineHandling.None;

            try
            {
                using (XmlWriter writer = XmlWriter.Create(cacheFile, settings))
                {
                    nav.WriteSubtree(writer);
                }
            }
            catch (Exception)
            {
                // derp!
            }
        }
Ejemplo n.º 6
0
 private void Initialize(XPathNavigator navigator)
 {
   using (MemoryStream memStream = new MemoryStream())
   {
     using (XmlWriter writer = XmlWriter.Create(memStream))
     {
       navigator.WriteSubtree(writer);
       writer.Flush();
       memStream.Position = 0;
       Initialize(memStream);
     }
   }
 }
Ejemplo n.º 7
0
 public static Stream NavigatorToStream(XPathNavigator nav){
     var sw = new MemoryStream();
     var w = new XmlTextWriter(sw, Encoding.UTF8);
     nav.WriteSubtree(w);
     w.Flush();
     sw.Position = 0;
     return sw;
 }
Ejemplo n.º 8
0
        protected static XElement GetXElement(XPathNavigator navigator)
        {
            XDocument xDoc = new XDocument();

            using (XmlWriter xmlWriter = xDoc.CreateWriter())

                navigator.WriteSubtree(xmlWriter);

            return xDoc.Root;
        }