本文整理汇总了C#中Xml.Tag方法的典型用法代码示例。如果您正苦于以下问题:C# Xml.Tag方法的具体用法?C# Xml.Tag怎么用?C# Xml.Tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xml
的用法示例。
在下文中一共展示了Xml.Tag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Xml_CData_AddsCDataNode
public void Xml_CData_AddsCDataNode()
{
var xml = new Xml();
xml.Tag("tag", Xml.Fragment(() =>
{
xml.CData("content");
xml.Tag("hello", "world");
}));
Assert.Equal("<tag><![CDATA[content]]><hello>world</hello></tag>", xml);
}
示例2: Xml_ToString_IndentTrue_UsingUtf8_WithDeclaration_OutputsProperString
public void Xml_ToString_IndentTrue_UsingUtf8_WithDeclaration_OutputsProperString()
{
var xml = new Xml();
xml.Declaration(encoding: "utf-8");
xml.Tag("outer", Xml.Fragment(() => xml.Tag("inner")));
Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<outer>\r\n <inner />\r\n</outer>", xml.ToString(true));
}
示例3: Xml_ToString_IndentTrue_UsingUtf8_NoDeclaration_OutputsProperString
public void Xml_ToString_IndentTrue_UsingUtf8_NoDeclaration_OutputsProperString()
{
var xml = new Xml();
xml.Tag("outer", Xml.Fragment(() => xml.Tag("inner")));
Assert.Equal("<outer>\r\n <inner />\r\n</outer>", xml.ToString(true));
}
示例4: Xml_ToString_IndentFalse_UsingUtf16_WithDeclaration_OutputsProperString
public void Xml_ToString_IndentFalse_UsingUtf16_WithDeclaration_OutputsProperString()
{
var xml = new Xml();
xml.Declaration(encoding: "utf-16");
xml.Tag("outer", Xml.Fragment(() => xml.Tag("inner")));
Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-16\"?><outer><inner /></outer>", xml.ToString(false));
}
示例5: Xml_Declaration_SetsAllParamsToDeclaration
public void Xml_Declaration_SetsAllParamsToDeclaration()
{
var xml = new Xml();
xml.Declaration(encoding: "utf-16", standalone: "yes");
xml.Tag("hello");
Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?><hello />", xml);
}
示例6: Xml_ToXmlNode_WithDocType_ReturnsProperNode
public void Xml_ToXmlNode_WithDocType_ReturnsProperNode()
{
var xml = new Xml();
// shouldn't return this doc type as the node even though
// it will now technicall be first node
xml.DocumentType("html");
xml.Tag("tag", "value");
XmlNode output = xml.ToXmlNode();
Assert.Equal("tag", output.Name);
}
示例7: Xml_Tag_ObjectAttributeArguments_ConvertsToAttributes
public void Xml_Tag_ObjectAttributeArguments_ConvertsToAttributes()
{
var xml = new Xml();
xml.Tag("tag", new { a = "b", x = 9, z = true });
Assert.Equal("<tag a=\"b\" x=\"9\" z=\"true\" />", xml);
}
示例8: Xml_ToXmlElement_ReturnsNodeAsXmlElement
public void Xml_ToXmlElement_ReturnsNodeAsXmlElement()
{
var xml = new Xml();
xml.Tag("tag", "value");
XmlElement output = xml.ToXmlElement();
Assert.Equal("tag", output.Name);
}
示例9: Xml_Tag_EscapedTagNameWithSameNameAsMethod_Escapes
public void Xml_Tag_EscapedTagNameWithSameNameAsMethod_Escapes()
{
var xml = new Xml();
// .Comment would have been a reserved call for declaring an xml comment
// so _ escapes it
xml.Tag("_Comment");
Assert.Equal("<Comment />", xml);
}
示例10: Xml_Tag_Name_BecomesTagName
public void Xml_Tag_Name_BecomesTagName()
{
var xml = new Xml();
xml.Tag("hello");
Assert.Equal("<hello />", xml);
}
示例11: Xml_Tag_DynamicActionArguments_CreateNestedNodes
public void Xml_Tag_DynamicActionArguments_CreateNestedNodes()
{
var xml = new Xml();
xml.Tag("outer", Xml.Fragment(outer =>
{
outer.Tag("inner1", Xml.Fragment(inner1 =>
{
inner1.Tag("inner2");
}));
}));
Assert.Equal("<outer><inner1><inner2 /></inner1></outer>", xml);
}
示例12: Xml_Tag_Combo_String_And_Attributes_ReturnsProperNode
public void Xml_Tag_Combo_String_And_Attributes_ReturnsProperNode()
{
var xml = new Xml();
xml.Tag("tag", "value", new { a = "b" });
Assert.Equal("<tag a=\"b\">value</tag>", xml);
}
示例13: Xml_Tag_Combo_Attributes_And_Fragment_ReturnsProperNode
public void Xml_Tag_Combo_Attributes_And_Fragment_ReturnsProperNode()
{
var xml = new Xml();
xml.Tag("tag", new { a = "b" }, Xml.Fragment(inner => inner.Tag("inner", "innerval")));
Assert.Equal("<tag a=\"b\"><inner>innerval</inner></tag>", xml);
}
示例14: Xml_ToXDocument_ReturnsProperXDocument
public void Xml_ToXDocument_ReturnsProperXDocument()
{
var xml = new Xml();
xml.Tag("tag", "value");
XDocument output = xml.ToXDocument();
Assert.Equal("<tag>value</tag>", output.FirstNode.ToString());
}
示例15: Xml_Tag_ObjectAttributeXmlnsArgumetns_ConvertsToActualXmlNamespaces
public void Xml_Tag_ObjectAttributeXmlnsArgumetns_ConvertsToActualXmlNamespaces()
{
var xml = new Xml();
xml.Tag("tag", new { a = "b", xmlns="http://www.w3.org/2005/Atom" });
Assert.Equal("http://www.w3.org/2005/Atom", xml.ToXElement().Name.NamespaceName);
Assert.Equal("<tag a=\"b\" xmlns=\"http://www.w3.org/2005/Atom\" />", xml);
}