本文整理汇总了C#中XmlDocument.CreateCDataSection方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument.CreateCDataSection方法的具体用法?C# XmlDocument.CreateCDataSection怎么用?C# XmlDocument.CreateCDataSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlDocument
的用法示例。
在下文中一共展示了XmlDocument.CreateCDataSection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertDataBeyondEndOfCdataNodeBigNumber
public static void InsertDataBeyondEndOfCdataNodeBigNumber()
{
var xmlDocument = new XmlDocument();
var cdataNode = (XmlCharacterData)xmlDocument.CreateCDataSection("hello");
Assert.Throws<ArgumentOutOfRangeException>(() => cdataNode.InsertData(10, "hello "));
}
示例2: CreateEmptyCdata
public static void CreateEmptyCdata()
{
var xmlDocument = new XmlDocument();
var cdataNode = (XmlCharacterData)xmlDocument.CreateCDataSection(String.Empty);
Assert.Equal(0, cdataNode.Length);
}
示例3: CreateCdata
public static void CreateCdata()
{
var xmlDocument = new XmlDocument();
var cdataNode = (XmlCharacterData)xmlDocument.CreateCDataSection("abcde");
Assert.Equal(5, cdataNode.Length);
}
示例4: SubstringBeforeBeginning
public static void SubstringBeforeBeginning()
{
var xmlDocument = new XmlDocument();
var cdataNode = (XmlCharacterData)xmlDocument.CreateCDataSection("abcde");
Assert.Throws<ArgumentOutOfRangeException>(() => cdataNode.Substring(-1, 1));
}
示例5: NameOfAllTypes
public static void NameOfAllTypes()
{
var xmlDocument = new XmlDocument();
var element = xmlDocument.CreateElement("newElem");
Assert.Equal("newElem", element.Name);
var attribute = xmlDocument.CreateAttribute("newAttr");
Assert.Equal("newAttr", attribute.Name);
var text = xmlDocument.CreateTextNode("");
Assert.Equal("#text", text.Name);
var cdata = xmlDocument.CreateCDataSection("");
Assert.Equal("#cdata-section", cdata.Name);
var pi = xmlDocument.CreateProcessingInstruction("PI", "");
Assert.Equal("PI", pi.Name);
var comment = xmlDocument.CreateComment("some text");
Assert.Equal("#comment", comment.Name);
var fragment = xmlDocument.CreateDocumentFragment();
Assert.Equal("#document-fragment", fragment.Name);
}
示例6: LengthOfCdataAfterDelete
public static void LengthOfCdataAfterDelete()
{
var xmlDocument = new XmlDocument();
var cdataNode = (XmlCharacterData)xmlDocument.CreateCDataSection("abcde");
cdataNode.DeleteData(0, 1);
Assert.Equal(4, cdataNode.Length);
}
示例7: InsertCDataNodeToDocumentNode
public static void InsertCDataNodeToDocumentNode()
{
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml("<a/>");
var cDataSection = xmlDocument.CreateCDataSection("data");
Assert.Throws<InvalidOperationException>(() => xmlDocument.InsertBefore(cDataSection, null));
}
示例8: EmptyString
public static void EmptyString()
{
var xmlDocument = new XmlDocument();
var cdataNode = (XmlCharacterData)xmlDocument.CreateCDataSection(String.Empty);
var subString = cdataNode.Substring(0, 10);
Assert.Equal(String.Empty, subString);
}
示例9: CDataNodeNode
public static void CDataNodeNode()
{
var xmlDocument = new XmlDocument();
var node = xmlDocument.CreateCDataSection("cdata section");
Assert.Equal("cdata section", node.Value);
node.Value = "new cdata";
Assert.Equal("new cdata", node.Value);
}
示例10: ReplaceAllCharactersFromCdataNodeBeginning
public static void ReplaceAllCharactersFromCdataNodeBeginning()
{
var xmlDocument = new XmlDocument();
var cdataNode = (XmlCharacterData)xmlDocument.CreateCDataSection("abcdefgh");
cdataNode.ReplaceData(0, cdataNode.Length, "new string");
Assert.Equal("new string", cdataNode.Data);
}
示例11: Replace4CharactersFromCdataNode
public static void Replace4CharactersFromCdataNode()
{
var xmlDocument = new XmlDocument();
var cdataNode = (XmlCharacterData)xmlDocument.CreateCDataSection("abcde");
cdataNode.ReplaceData(1, 4, "test");
Assert.Equal("atest", cdataNode.Data);
}
示例12: Replace1CharactersFromCdataNodeBeginning
public static void Replace1CharactersFromCdataNodeBeginning()
{
var xmlDocument = new XmlDocument();
var cdataNode = (XmlCharacterData)xmlDocument.CreateCDataSection("abcde");
cdataNode.ReplaceData(0, 1, "&");
Assert.Equal("&bcde", cdataNode.Data);
}
示例13: InsertDataInEmptyCdataNode
public static void InsertDataInEmptyCdataNode()
{
var xmlDocument = new XmlDocument();
var cdataNode = (XmlCharacterData)xmlDocument.CreateCDataSection(null);
cdataNode.InsertData(0, "hello");
Assert.Equal("hello", cdataNode.Data);
}
示例14: InsertDataAtMiddleOfCdataNode
public static void InsertDataAtMiddleOfCdataNode()
{
var xmlDocument = new XmlDocument();
var cdataNode = (XmlCharacterData)xmlDocument.CreateCDataSection("comment");
cdataNode.InsertData(3, " hello ");
Assert.Equal("com hello ment", cdataNode.Data);
}
示例15: CreateCDataTest2
public static void CreateCDataTest2()
{
var xmlDocument = new XmlDocument();
var cdata = xmlDocument.CreateCDataSection("test data");
Assert.Equal("<![CDATA[test data]]>", cdata.OuterXml);
Assert.Equal(String.Empty, cdata.InnerXml);
Assert.Equal("test data", cdata.InnerText);
Assert.Equal(XmlNodeType.CDATA, cdata.NodeType);
}