本文整理汇总了C#中System.Xml.XmlWriter.WriteName方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.WriteName方法的具体用法?C# XmlWriter.WriteName怎么用?C# XmlWriter.WriteName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.WriteName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteXml
public void WriteXml(XmlWriter writer)
{
foreach (var key in this.Properties.Keys)
{
writer.WriteStartElement("entry");
writer.WriteStartElement("key");
writer.WriteName(key);
writer.WriteEndElement();
var value = this.Properties[key];
// Configure serializer behavior for element and attributes
var genericSerializer = new GenericSerializer();
genericSerializer.AddAttributeObjectBinding(
new XmlAttribute(typeof(Details), "xmlns:xsi", ScenarioDocuXMLFileUtil.SchemaInstanceNamespace));
// Prepare elment and attribute names
genericSerializer.AddAttributeObjectBinding(new XmlAttribute(typeof(Details), "xsi:type", "details"));
genericSerializer.AddElementObjectBinding(new XmlElement(typeof(Details), "value"), typeof(Details));
genericSerializer.AddElementObjectBinding(
new XmlElement(typeof(ObjectDescription), "value"), typeof(ObjectDescription));
genericSerializer.AddElementObjectBinding(
new XmlElement(typeof(ObjectReference), "value"), typeof(ObjectReference));
genericSerializer.AddElementObjectBinding(
new XmlElement(typeof(ObjectList<>), "value"), typeof(ObjectList<>));
// Prepare xml tags
genericSerializer.AddXmlTag(
new XmlTag(
new XmlElement(typeof(ObjectTreeNode<object>), "value"),
new List<XmlAttribute>
{
new XmlAttribute(
"xmlns:xsi", ScenarioDocuXMLFileUtil.SchemaInstanceNamespace),
new XmlAttribute("xsi:type", "objectTreeNode")
},
typeof(ObjectTreeNode<object>)),
typeof(ObjectTreeNode<object>));
genericSerializer.SuppressProperties = false;
genericSerializer.DetailElementName = "value";
genericSerializer.SerializeDetails(writer, value);
writer.WriteEndElement();
}
}
示例2: WriteTo
public override void WriteTo (XmlWriter w)
{
w.WriteRaw ("&");
w.WriteName (Name);
w.WriteRaw (";");
}
示例3: InvokeMethod
private void InvokeMethod(XmlWriter w, string methodName)
{
byte[] buffer = new byte[10];
switch (methodName)
{
case "WriteStartDocument":
w.WriteStartDocument();
break;
case "WriteStartElement":
w.WriteStartElement("root");
break;
case "WriteEndElement":
w.WriteEndElement();
break;
case "WriteStartAttribute":
w.WriteStartAttribute("attr");
break;
case "WriteEndAttribute":
w.WriteEndAttribute();
break;
case "WriteCData":
w.WriteCData("test");
break;
case "WriteComment":
w.WriteComment("test");
break;
case "WritePI":
w.WriteProcessingInstruction("name", "test");
break;
case "WriteEntityRef":
w.WriteEntityRef("e");
break;
case "WriteCharEntity":
w.WriteCharEntity('c');
break;
case "WriteSurrogateCharEntity":
w.WriteSurrogateCharEntity('\uDC00', '\uDBFF');
break;
case "WriteWhitespace":
w.WriteWhitespace(" ");
break;
case "WriteString":
w.WriteString("foo");
break;
case "WriteChars":
char[] charArray = new char[] { 'a', 'b', 'c', 'd' };
w.WriteChars(charArray, 0, 3);
break;
case "WriteRaw":
w.WriteRaw("<foo>bar</foo>");
break;
case "WriteBase64":
w.WriteBase64(buffer, 0, 9);
break;
case "WriteBinHex":
w.WriteBinHex(buffer, 0, 9);
break;
case "LookupPrefix":
string str = w.LookupPrefix("foo");
break;
case "WriteNmToken":
w.WriteNmToken("foo");
break;
case "WriteName":
w.WriteName("foo");
break;
case "WriteQualifiedName":
w.WriteQualifiedName("foo", "bar");
break;
case "WriteValue":
w.WriteValue(Int32.MaxValue);
break;
case "WriteAttributes":
XmlReader xr1 = ReaderHelper.Create(new StringReader("<root attr='test'/>"));
xr1.Read();
w.WriteAttributes(xr1, false);
break;
case "WriteNodeReader":
XmlReader xr2 = ReaderHelper.Create(new StringReader("<root/>"));
xr2.Read();
w.WriteNode(xr2, false);
break;
case "Flush":
w.Flush();
break;
default:
CError.Equals(false, "Unexpected param in testcase: {0}", methodName);
break;
}
}
示例4: write
public void write()
{
using (this.writer = XmlWriter.Create(write_fname))
{
writer.WriteStartDocument();
writer.WriteStartElement("world");
writer.WriteAttributeString("X", Convert.ToString(LevelScreen.GAME_WIDTH));
writer.WriteAttributeString("Y", Convert.ToString(LevelScreen.GAME_HEIGHT));
writer.WriteStartElement("player");
writer.WriteAttributeString("X", Convert.ToString((int)this.playerController.thePlayer.position.X));
writer.WriteAttributeString("Y", Convert.ToString((int)this.playerController.thePlayer.position.Y));
writer.WriteFullEndElement();
foreach (Obstacle o in this.obstacleController.obstacles)
{
writer.WriteStartElement("obstacle");
writer.WriteAttributeString("X", Convert.ToString((int)o.position.X));
writer.WriteAttributeString("Y", Convert.ToString((int)o.position.Y));
string type = "";
switch (o.tag)
{
case ObstacleType.Bush:
type = "Bush";
break;
case ObstacleType.Fountain:
type = "Fountain";
break;
case ObstacleType.Pond:
type = "Pond";
break;
case ObstacleType.Tree:
type = "Tree";
break;
case ObstacleType.Border:
type = "Border";
break;
}
writer.WriteName(type);
writer.WriteFullEndElement();
}
foreach (Item i in this.itemController.activeItems)
{
writer.WriteStartElement("item");
writer.WriteAttributeString("X", Convert.ToString((int)i.position.X));
writer.WriteAttributeString("Y", Convert.ToString((int)i.position.Y));
string type = "";
switch (i.tag)
{
case ItemType.Apple:
type = "Apple";
break;
case ItemType.CandyBar:
type = "CandyBar";
break;
case ItemType.WaterBottle:
type = "WaterBottle";
break;
case ItemType.Coin:
type = "Coin";
break;
}
writer.WriteName(type);
writer.WriteFullEndElement();
}
foreach (NPC n in this.npcController.npcs)
{
writer.WriteStartElement("npc");
writer.WriteAttributeString("X", Convert.ToString((int)n.position.X));
writer.WriteAttributeString("Y", Convert.ToString((int)n.position.Y));
string type = "";
switch (n.tag)
{
case NPCType.Bird:
type = "Bird";
break;
case NPCType.Child:
type = "Child";
break;
case NPCType.PoliceA:
type = "PoliceA";
break;
case NPCType.PoliceB:
type = "PoliceB";
break;
case NPCType.Squirrel:
type = "Squirrel";
break;
}
writer.WriteName(type);
writer.WriteFullEndElement();
}
writer.WriteFullEndElement();
}
writer.Close();
}