本文整理汇总了C#中System.Xml.XmlTextWriter.WriteComment方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextWriter.WriteComment方法的具体用法?C# XmlTextWriter.WriteComment怎么用?C# XmlTextWriter.WriteComment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextWriter
的用法示例。
在下文中一共展示了XmlTextWriter.WriteComment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriterXml
/// <summary>
/// 写入配置参数数据
/// </summary>
/// <param name="Path"></param>
public void WriterXml(string Path)
{
try
{
// 创建XmlTextWriter类的实例对象
XmlTextWriter textWriter = new XmlTextWriter(Path, null);
textWriter.Formatting = Formatting.Indented;
// 开始写过程,调用WriteStartDocument方法
textWriter.WriteStartDocument();
// 写入说明
textWriter.WriteComment("First Comment XmlTextWriter Sample Example");
textWriter.WriteComment("w3sky.xml in root dir");
//创建一个节点
textWriter.WriteStartElement("Administrator");
textWriter.WriteElementString("Name", "formble");
textWriter.WriteElementString("site", "w3sky.com");
textWriter.WriteEndElement();
// 写文档结束,调用WriteEndDocument方法
textWriter.WriteEndDocument();
// 关闭textWriter
textWriter.Close();
}
catch (System.Exception e)
{
Console.WriteLine(e.ToString());
}
}
示例2: WriterXml
/// <summary>
/// 写入配置参数数据
/// </summary>
/// <param name="Path"></param>
public void WriterXml(string Path)
{
try
{
// 创建XmlTextWriter类的实例对象
XmlTextWriter textWriter = new XmlTextWriter(Path, null);
textWriter.Formatting = Formatting.Indented;
// 开始写过程,调用WriteStartDocument方法
textWriter.WriteStartDocument();
// 写入说明
textWriter.WriteComment("=====系统数据库定義=====");
//创建一个节点
textWriter.WriteStartElement("Parameter");
textWriter.WriteElementString("Server", "192.168.1.16");
textWriter.WriteElementString("Database", "RFIDDeliveryDB");
textWriter.WriteElementString("User", "SA");
textWriter.WriteElementString("Password", "");
textWriter.WriteComment("=====数据库类型=====");
textWriter.WriteElementString("DataSourceType", "1");
textWriter.WriteComment("=====日志文件=====");
textWriter.WriteElementString("LogFileName", "LogFiles");
textWriter.WriteComment("=====日志文件=====");
textWriter.WriteElementString("LogThreadFileName", "LogThreadFiles");
textWriter.WriteComment("=====手持设备参数=====");
textWriter.WriteElementString("Baud", "5");
textWriter.WriteElementString("Dminfre", "0");
textWriter.WriteElementString("Dmaxfre", "62");
textWriter.WriteElementString("PowerDbm", "30");
//数据上传更新间隔
textWriter.WriteElementString("UpInterval", "20000");
// 写文档结束
textWriter.WriteEndDocument();
// 关闭textWriter
textWriter.Close();
}
catch (System.Exception e)
{
Console.WriteLine(e.ToString());
}
}
示例3: Export
/// <summary>
/// Create a temporary XML file that will be send to SAP application
/// </summary>
/// <param name="m"></param>
/// <param name="filePath"></param>
internal void Export(Canguro.Model.Model m, string filePath)
{
String xmlfile = filePath.Substring(0, filePath.Length - 3) + "xml";
tmpxml = new XmlTextWriter(xmlfile, null);
Canguro.Model.UnitSystem.UnitSystem uSystem = m.UnitSystem;
m.UnitSystem = Canguro.Model.UnitSystem.InternationalSystem.Instance;
try {
tmpxml.Formatting = Formatting.Indented;
tmpxml.Indentation = 4;
tmpxml.Namespaces = false;
tmpxml.WriteStartDocument();
tmpxml.WriteComment("XML file generated by CanguroTeam");
tmpxml.WriteComment(DateTime.Now.ToString());
// node added for validation
tmpxml.WriteStartElement("XmlExportedFile");
// writing fix values for nodes
writeFixedNode(tmpxml);
//writing nodes for Joints
writeNode(tmpxml, m.JointList);
//writing nodes for Lines
writeNode(tmpxml, m.LineList);
//writing xml nodes for Materials
writeNode(tmpxml);
//writing xml nodes for Abstract cases
writeNode(tmpxml, m);
//writing xml nodes for Load cases
writeNode(tmpxml, m.LoadCases);
//writing xml nodes for concrete material
writeConcreteNode(tmpxml, m.ConcreteDesignOptions);
//writing xml nodes for steel material
writeSteelNode(tmpxml, m.SteelDesignOptions);
//writing xml nodes for frame design
writeFrameDesignNode(tmpxml, m);
//writing nodes for spectrum analysis
writeNode(tmpxml, m.ResponseSpectra, m.AbstractCases);
tmpxml.WriteEndElement();
tmpxml.Flush();
} catch(Exception e) {
System.Windows.Forms.MessageBox.Show(Culture.Get("XmlError"), Culture.Get("error"),
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
throw;
} finally {
if (tmpxml != null) {
tmpxml.Close();
m.UnitSystem = uSystem;
}
}
}
示例4: Save_XML
public void Save_XML(string path)
{
XmlTextWriter xmlTextWriter = new XmlTextWriter(path, null);
xmlTextWriter.Formatting = Formatting.Indented;
xmlTextWriter.WriteStartDocument(false);
xmlTextWriter.WriteComment("Xml from Juan converter");
xmlTextWriter.WriteStartElement("STB");
for (int num = 0; num != this.rowcount; num++)
{
xmlTextWriter.WriteStartElement("Entry");
xmlTextWriter.WriteAttributeString("id", num.ToString());
for (int num2 = 0; num2 != this.columncount; num2++)
{
if (this.column[num2].selected)
{
xmlTextWriter.WriteStartElement("Data");
xmlTextWriter.WriteAttributeString("type", this.column[num2].columntitle);
xmlTextWriter.WriteString(this.celldata[num, num2]);
xmlTextWriter.WriteEndElement();
}
}
xmlTextWriter.WriteEndElement();
}
xmlTextWriter.WriteEndElement();
xmlTextWriter.Flush();
xmlTextWriter.Close();
xmlTextWriter.Close();
}
示例5: Dump2Xml
/// <summary>
/// Converts the memory hash table to XML
/// </summary>
public void Dump2Xml()
{
if ((TheHt.Count > 0) && IsDirty)
{
var writer = new XmlTextWriter(string.Format("{0}", Filename), null);
writer.Formatting = Formatting.Indented;
writer.WriteStartDocument();
writer.WriteComment("Comments: " + Name);
writer.WriteStartElement("logfile-list");
var myEnumerator = TheHt.GetEnumerator();
while (myEnumerator.MoveNext())
{
var m = (LogItem)myEnumerator.Value;
WriteLogNode(writer, m);
}
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
Utility.Announce(string.Format("{0} created.", Filename));
}
else
Utility.Announce(string.Format("No changes to {0}.", Filename));
}
示例6: Dump2Xml
public void Dump2Xml()
{
if ( ( TheHt.Count <= 0 ) || !IsDirty )
{
Announce( "Cache not dirty" );
return;
}
Announce( string.Format( "Writing cache to {0}", Filename ) );
Utility.EnsureDirectory( Filename ); // will create the dir if its not there
var writer = new XmlTextWriter( Filename, null );
writer.WriteStartDocument();
writer.WriteComment( "Comments: " + Name );
writer.WriteStartElement( "stat-list" );
var myEnumerator = TheHt.GetEnumerator();
while ( myEnumerator.MoveNext() )
{
var t = ( YahooOutput ) myEnumerator.Value;
WriteStatNode( writer, t );
}
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
}
示例7: XMLWriterInit
public static void XMLWriterInit(XmlTextWriter XWriter)
{
XWriter.Formatting = Formatting.Indented;
XWriter.WriteStartDocument();
XWriter.WriteComment("XMLSerialised XBIM geometry");
XWriter.WriteStartElement("XBIMGeometry");
}
示例8: Save
public void Save(string path)
{
XmlTextWriter myXmlTextWriter = new XmlTextWriter(path, System.Text.Encoding.UTF8);
myXmlTextWriter.Formatting = Formatting.Indented;
myXmlTextWriter.WriteStartDocument(false);
myXmlTextWriter.WriteComment("Erstellt von gamenoise");
myXmlTextWriter.WriteStartElement("streams");
IEnumerator enumerator = _myStreams.GetEnumerator();
while (enumerator.MoveNext())
{
myXmlTextWriter.WriteStartElement("stream");
myXmlTextWriter.WriteElementString("title", ((Stream)enumerator.Current).Title);
myXmlTextWriter.WriteElementString("url", ((Stream)enumerator.Current).Url);
myXmlTextWriter.WriteElementString("genre", ((Stream)enumerator.Current).Genre);
myXmlTextWriter.WriteElementString("description", ((Stream)enumerator.Current).Description);
myXmlTextWriter.WriteEndElement();
}
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.Flush();
myXmlTextWriter.Close();
}
示例9: Dump2Xml
/// <summary>
/// Converts the memory hash table to XML
/// </summary>
public void Dump2Xml()
{
if ( ( TheHT.Count > 0 ) && IsDirty )
{
XmlTextWriter writer = new
XmlTextWriter( string.Format( "{0}", Filename ), null );
writer.WriteStartDocument();
writer.WriteComment( "Comments: " + Name );
writer.WriteStartElement( "media-list" );
IDictionaryEnumerator myEnumerator = TheHT.GetEnumerator();
while ( myEnumerator.MoveNext() )
{
MediaItem m = (MediaItem) myEnumerator.Value;
WriteMediaNode( writer, m );
}
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
Utility.Announce( string.Format( "{0} created.", Filename ) );
}
else
Utility.Announce( string.Format( "No changes to {0}.", Filename ) );
}
示例10: CreateXml
public void CreateXml()
{
if ( ( m_SeasonList.Count > 0 ) )
{
const string fileName = "NFL.xml";
XmlTextWriter writer = new
XmlTextWriter(string.Format("{0}{1}", Utility.OutputDirectory() + "xml\\", fileName), null);
writer.Formatting = Formatting.Indented;
writer.WriteStartDocument();
writer.WriteComment( "Comments: NFL Season List" );
writer.WriteStartElement( "nfl" );
writer.WriteStartElement("season-list");
foreach ( NflSeason s in m_SeasonList )
{
WriteSeasonNode( writer, s );
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
RosterLib.Utility.Announce( fileName + " created" );
}
}
示例11: buttonOK_Click
/// <summary>
/// Update XML Interplay, with count value.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonOK_Click(object sender, System.EventArgs e)
{
count = Convert.ToInt32(this.numericUpDown.Value);
try
{
using (XmlTextWriter counter = new XmlTextWriter("Interplay.xml", System.Text.Encoding.Default))
{
counter.WriteStartDocument(true);
counter.WriteComment("Just a small xml, dealing with the number of times a computer vs. computer would play");
counter.WriteStartElement("count");
counter.WriteString(this.numericUpDown.Value.ToString());
counter.WriteEndElement();
counter.WriteEndDocument();
}
}
catch (System.IO.FileNotFoundException)
{
//do nothing, use defaults
}
catch (Exception err)
{
MessageBox.Show(err.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
this.Close();
}
示例12: Dump2Xml
public void Dump2Xml()
{
if (_gameHt.Count > 0)
{
//DumpHt( gameHT );
var writer = new
XmlTextWriter(string.Format("{0}\\xml\\NFLGame.xml", Utility.OutputDirectory()), null);
writer.WriteStartDocument();
writer.WriteComment("Comments: Game Metrics");
writer.WriteStartElement("game-list");
var myEnumerator = _gameHt.GetEnumerator();
while (myEnumerator.MoveNext())
{
var g = (NFLGame) myEnumerator.Value;
WriteGameNode(writer, g);
if (g.GameDate >= DateTime.Now) continue;
if (g.AwayScore + g.HomeScore == 0)
Utility.Announce(string.Format("Suspect game [{0}]:", g.ScoreOut()));
}
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
Utility.Announce(string.Format(" {0}\\xml\\NFLGame.xml created", Utility.OutputDirectory()));
}
}
示例13: Execute
public override bool Execute()
{
string pdbxmlFile = Path.ChangeExtension(AssemblyName.ItemSpec, ".pdb.xml");
_pddxmlFile = new TaskItem(pdbxmlFile);
xwriter = new XmlTextWriter(pdbxmlFile, null);
xwriter.Formatting = Formatting.Indented;
//Log.LogMessage("Get symbol reader for file {0}", Path.ChangeExtension(AssemblyName.ItemSpec, ".pdb"));
ISymbolReader reader = SymUtil.GetSymbolReaderForFile(AssemblyName.ItemSpec, null);
//Log.LogMessage("Load assembly");
m_assembly = System.Reflection.Assembly.LoadFrom(AssemblyName.ItemSpec);
// Begin writing XML.
xwriter.WriteStartDocument();
xwriter.WriteComment("This is an XML file representing the PDB for '" + AssemblyName.ItemSpec + "'");
xwriter.WriteStartElement("Types");
// Record what input file these symbols are for.
xwriter.WriteAttributeString("file", AssemblyName.ItemSpec);
//WriteDocList(reader);
WriteTypesAndDocs(reader);
xwriter.WriteEndElement(); // "Symbols";
xwriter.Close();
return !Log.HasLoggedErrors;
}
示例14: Build
internal string Build()
{
using (MemoryStream ms = new MemoryStream())
{
using (XmlTextWriter xml = new XmlTextWriter(ms, new UTF8Encoding(false)) { Formatting = Formatting.Indented })
{
xml.WriteStartDocument();
string license = this.GetLicense();
xml.WriteComment(license);
xml.WriteStartElement("MixERPReport");
xml.WriteElementString("Title", this.Definition.Title);
this.WriteTopSection(xml);
this.WriteBody(xml);
this.WriteBottomSection(xml);
this.WriteDataSources(xml);
this.WriteMenu(xml);
}
return Encoding.UTF8.GetString(ms.ToArray());
}
}
示例15: exportTopic
public void exportTopic(string p_ID, Topic p_Topic)
{
Settings l_Settings = Settings.Instance;
//File overwritten when already existing
XmlTextWriter l_Writer = new XmlTextWriter(l_Settings.TopicsDir + p_ID + ".xml", Encoding.UTF8);
l_Writer.Formatting = Formatting.Indented;
try
{
l_Writer.WriteStartDocument();
l_Writer.WriteComment("ggplot2 topic.");
l_Writer.WriteStartElement("Topic");
l_Writer.WriteStartElement("Title");
l_Writer.WriteString(p_Topic.Title);
l_Writer.WriteEndElement();
l_Writer.WriteStartElement("ID");
l_Writer.WriteString(p_Topic.ID);
l_Writer.WriteEndElement();
l_Writer.WriteStartElement("Messages");
for (int j = 0; j < p_Topic.Messages.Count; j++)
{
l_Writer.WriteStartElement("Message");
l_Writer.WriteStartElement("User");
l_Writer.WriteStartElement("Name");
l_Writer.WriteString(p_Topic.Messages[j].UserName);
l_Writer.WriteEndElement();
l_Writer.WriteStartElement("Avatar");
l_Writer.WriteString(p_Topic.Messages[j].Avatar);
l_Writer.WriteEndElement();
l_Writer.WriteStartElement("Email");
l_Writer.WriteString(p_Topic.Messages[j].Email);
l_Writer.WriteEndElement();
l_Writer.WriteEndElement();//~User
l_Writer.WriteStartElement("date");
l_Writer.WriteString(p_Topic.Messages[j].Date);
l_Writer.WriteEndElement();
l_Writer.WriteStartElement("content");
l_Writer.WriteString(p_Topic.Messages[j].Content);
l_Writer.WriteEndElement();
l_Writer.WriteEndElement();//~Message
}
l_Writer.WriteEndElement();//~Messages
l_Writer.WriteEndElement();//~Topic
l_Writer.WriteEndDocument();
l_Writer.Flush();
l_Writer.Close();
}
catch (Exception e)
{
l_Writer.Flush();
l_Writer.Close();
if (l_Settings.DebugMode)
debug("Exception in exportTopic(): " + e.Message);
}
}