private static string WriteXml(XmlElement element)
 {
     using(var sw = new StringWriter())
     {
         using(var xw = XmlWriter.Create(sw))
         { 
             element.WriteTo(xw);
             xw.Flush();
             return sw.ToString();
         }
     }
 }
Example #2
0
        void OnProtocol(object sender, XmlElement tag)
        {
            if (!DebugProtocol) {
                return;
            }

            try {
                var strWriter = new StringWriter();
                var xmlWriter = new XmlTextWriter(strWriter);
                xmlWriter.Formatting = Formatting.Indented;
                xmlWriter.Indentation = 2;
                xmlWriter.IndentChar =  ' ';
                tag.WriteTo(xmlWriter);

                DebugRead("\n" + strWriter.ToString());
            } catch (Exception ex) {
            #if LOG4NET
                _Logger.Error("OnProtocol(): Exception", ex);
            #endif
            }
        }
 private static string WriteXml(XmlElement element)
 {
     using(var text = new StringWriter())
     {
         using(var xml = new XmlTextWriter(text))
         { 
             element.WriteTo(xml);
             return text.ToString();
         }
     }
 }
Example #4
0
        private string WriteXml(XmlElement elem)
        {
            var settings = new XmlWriterSettings();
              settings.OmitXmlDeclaration = true;
              settings.Indent = true;
              settings.IndentChars = "  ";

              using (var writer = new StringWriter())
              {
            using (var xml = XmlTextWriter.Create(writer, settings))
            {
              elem.WriteTo(xml);
            }
            return writer.ToString();
              }
        }
		/// <summary>
		/// Creates an XML fragment string for the specified element.
		/// </summary>
		/// <param name="lineTerminator">The line terminator.</param>
		/// <param name="tabsToSpaces">Indicates whether tabs will be converted to spaces.</param>
		/// <param name="tabIndent">The indent to be used when converting tabs to spaces.</param>
		/// <returns>An XML fragment string without any Wix namespace attributes.</returns>
		public static string GetXml(XmlElement element, string lineTerminator, bool tabsToSpaces, int tabIndent)
		{
			StringBuilder xml = new StringBuilder();
			StringWriter stringWriter = new StringWriter(xml);
			XmlWriterSettings xmlWriterSettings = CreateXmlWriterSettings(lineTerminator, tabsToSpaces, tabIndent);
			using (XmlWriter xmlWriter = XmlTextWriter.Create(stringWriter, xmlWriterSettings)) {
				element.WriteTo(xmlWriter);
			}
			return xml.ToString().Replace(String.Concat(" xmlns=\"", WixNamespaceManager.Namespace, "\""), String.Empty);;
		}
Example #6
0
        void OnProtocol(object sender, XmlElement tag)
        {
            if (!DebugProtocol) {
                return;
            }

            var strWriter = new StringWriter();
            var xmlWriter = new XmlTextWriter(strWriter);
            xmlWriter.Formatting = Formatting.Indented;
            xmlWriter.Indentation = 2;
            xmlWriter.IndentChar =  ' ';
            tag.WriteTo(xmlWriter);

            DebugRead("\n" + strWriter.ToString());
        }
Example #7
0
	private static void WriteXml(XmlElement element, System.IO.TextWriter output) {
		XmlTextWriter writer = new XmlTextWriter(output);
		writer.Formatting = Formatting.Indented;
		writer.Indentation = 4;
		writer.IndentChar = ' ';
		element.WriteTo(writer);
		output.WriteLine();	
	}
Example #8
0
    public async Task ToAml(Stream stream, XmlElement elem)
    {
      var settings = new XmlWriterSettings();
      settings.OmitXmlDeclaration = true;
      settings.Indent = true;
      settings.IndentChars = "  ";
      settings.CheckCharacters = true;

      using (var xmlWriter = XmlWriter.Create(stream, settings))
      {
        elem.WriteTo(xmlWriter);
      }
    }
		/// <summary>
		/// Loads the specified element.
		/// </summary>
		/// <param name="element">The element.</param>
		public virtual void Load(XmlElement element)
		{
			StringBuilder xmlTextBuilder = new StringBuilder();
			XmlWriter     xmlWriter      = new XmlTextWriter(new StringWriter(xmlTextBuilder));

			element.WriteTo(xmlWriter);

			StringReader stringReader = new StringReader(xmlTextBuilder.ToString());
			XmlReader    reader       = XmlReader.Create(stringReader);

			this.Load(reader);
		}