本文整理汇总了C#中System.Xml.XmlTextWriter.WriteValue方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextWriter.WriteValue方法的具体用法?C# System.Xml.XmlTextWriter.WriteValue怎么用?C# System.Xml.XmlTextWriter.WriteValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextWriter
的用法示例。
在下文中一共展示了System.Xml.XmlTextWriter.WriteValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsolatedStorage_Read_and_Write_Sample
public static void IsolatedStorage_Read_and_Write_Sample()
{
string fileName = @"SelfWindow.xml";
IsolatedStorageFile storFile = IsolatedStorageFile.GetUserStoreForDomain();
IsolatedStorageFileStream storStream = new IsolatedStorageFileStream(fileName, FileMode.Create, FileAccess.Write);
System.Xml.XmlWriter writer = new System.Xml.XmlTextWriter(storStream, Encoding.UTF8);
writer.WriteStartDocument();
writer.WriteStartElement("Settings");
writer.WriteStartElement("UserID");
writer.WriteValue(42);
writer.WriteEndElement();
writer.WriteStartElement("UserName");
writer.WriteValue("kingwl");
writer.WriteEndElement();
writer.WriteEndElement();
writer.Flush();
writer.Close();
storStream.Close();
string[] userFiles = storFile.GetFileNames();
foreach(var userFile in userFiles)
{
if(userFile == fileName)
{
var storFileStreamnew = new IsolatedStorageFileStream(fileName,FileMode.Open,FileAccess.Read);
StreamReader storReader = new StreamReader(storFileStreamnew);
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(storReader);
int UserID = 0;
string UserName = null;
while(reader.Read())
{
switch(reader.Name)
{
case "UserID":
UserID = int.Parse(reader.ReadString());
break;
case "UserName":
UserName = reader.ReadString();
break;
default:
break;
}
}
Console.WriteLine("{0} {1}", UserID, UserName);
storFileStreamnew.Close();
}
}
storFile.Close();
}
示例2: Save
public void Save()
{
System.Xml.XmlTextWriter settingsXML = new System.Xml.XmlTextWriter("settings.xml", System.Text.Encoding.UTF8);
settingsXML.WriteStartDocument();
settingsXML.WriteStartElement("settings");
settingsXML.WriteStartElement("display");
settingsXML.WriteStartAttribute("fullscreen");
settingsXML.WriteValue(fullscreen);
settingsXML.WriteStartAttribute("resolutionX");
settingsXML.WriteValue(resolutionX);
settingsXML.WriteStartAttribute("resolutionY");
settingsXML.WriteValue(resolutionY);
settingsXML.WriteEndElement();
settingsXML.WriteEndElement();
settingsXML.WriteEndDocument();
settingsXML.Close();
}
示例3: ReturnSupportedFeatures
//e.g. Worklist, CurveData, Attachment_Type, Attachment_Path
protected virtual string ReturnSupportedFeatures()
{
//<?xml version="1.0" encoding="utf-16"?>
//<ndd>
// <Command Type="SupportedFeatures">
// <Parameter Name="SearchPatients"></Parameter>
// </Command>
//</ndd>
StringBuilder sb = new System.Text.StringBuilder();
using (System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(new System.IO.StringWriter(sb, CultureInfo.InvariantCulture)))
{
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("ndd");
xmlWriter.WriteStartElement("Command");
xmlWriter.WriteAttributeString("Type", Commands.SupportedFeatures.Command);
foreach (string strFeature in GetSupportedFeatures())
{
xmlWriter.WriteStartElement("Parameter");
xmlWriter.WriteAttributeString("Name", strFeature);
xmlWriter.WriteValue("True");
xmlWriter.WriteEndElement();//parameter
}
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
// xmlWriter.WriteString(@"
//<ndd>
//<command>Test xml data</command><Patients>
// <Patient ID=""PSM-11213"">
// <LastName>Smith</LastName>
// <FirstName>Peter</FirstName></Patient>
//</Patients>
//</ndd>");
xmlWriter.Flush();
xmlWriter.Close();
return sb.ToString();
}
}