本文整理汇总了C#中IXmlDocument.CreateXmlDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C# IXmlDocument.CreateXmlDeclaration方法的具体用法?C# IXmlDocument.CreateXmlDeclaration怎么用?C# IXmlDocument.CreateXmlDeclaration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXmlDocument
的用法示例。
在下文中一共展示了IXmlDocument.CreateXmlDeclaration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateInstruction
private void CreateInstruction(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string propertyName)
{
if (propertyName == DeclarationName)
{
string version = null;
string encoding = null;
string standalone = null;
while (reader.Read() && reader.TokenType != JsonToken.EndObject)
{
switch (reader.Value.ToString())
{
case "@version":
reader.Read();
version = reader.Value.ToString();
break;
case "@encoding":
reader.Read();
encoding = reader.Value.ToString();
break;
case "@standalone":
reader.Read();
standalone = reader.Value.ToString();
break;
default:
throw new JsonSerializationException("Unexpected property name encountered while deserializing XmlDeclaration: " + reader.Value);
}
}
IXmlNode declaration = document.CreateXmlDeclaration(version, encoding, standalone);
currentNode.AppendChild(declaration);
}
else
{
IXmlNode instruction = document.CreateProcessingInstruction(propertyName.Substring(1), reader.Value.ToString());
currentNode.AppendChild(instruction);
}
}
示例2: CreateInstruction
// Token: 0x060006E9 RID: 1769
// RVA: 0x00038868 File Offset: 0x00036A68
private void CreateInstruction(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string propertyName)
{
if (propertyName == "?xml")
{
string version = null;
string encoding = null;
string standalone = null;
while (reader.Read())
{
if (reader.TokenType == JsonToken.EndObject)
{
break;
}
string a;
if ((a = reader.Value.ToString()) != null)
{
if (a == "@version")
{
reader.Read();
version = reader.Value.ToString();
continue;
}
if (a == "@encoding")
{
reader.Read();
encoding = reader.Value.ToString();
continue;
}
if (a == "@standalone")
{
reader.Read();
standalone = reader.Value.ToString();
continue;
}
}
throw new JsonSerializationException("Unexpected property name encountered while deserializing XmlDeclaration: " + reader.Value);
}
IXmlNode newChild = document.CreateXmlDeclaration(version, encoding, standalone);
currentNode.AppendChild(newChild);
return;
}
IXmlNode newChild2 = document.CreateProcessingInstruction(propertyName.Substring(1), reader.Value.ToString());
currentNode.AppendChild(newChild2);
}