本文整理汇总了C#中System.Xml.XmlElement.WriteTo方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.WriteTo方法的具体用法?C# XmlElement.WriteTo怎么用?C# XmlElement.WriteTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlElement
的用法示例。
在下文中一共展示了XmlElement.WriteTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteXml
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();
}
}
}
示例2: OnProtocol
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
}
}
示例3: WriteXml
private static string WriteXml(XmlElement element)
{
using(var text = new StringWriter())
{
using(var xml = new XmlTextWriter(text))
{
element.WriteTo(xml);
return text.ToString();
}
}
}
示例4: WriteXml
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();
}
}
示例5: GetXml
/// <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);;
}
示例6: OnProtocol
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());
}
示例7: WriteXml
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();
}
示例8: ToAml
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);
}
}
示例9: Load
/// <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);
}