本文整理匯總了C#中System.Xml.XmlTextReader.ReadChars方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.ReadChars方法的具體用法?C# XmlTextReader.ReadChars怎麽用?C# XmlTextReader.ReadChars使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadChars方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ReadCharsWithVeryLimitedBuffer
[Test] // bug #675384
public void ReadCharsWithVeryLimitedBuffer ()
{
var r = new XmlTextReader ("<root><child>a</child></root>", XmlNodeType.Document, null);
r.MoveToContent ();
char [] buff = new char [1];
int read = 0;
var sb = new StringBuilder ();
do {
read = r.ReadChars (buff, 0, buff.Length);
if (read > 0)
sb.Append (buff [0]);
} while (read > 0);
Assert.AreEqual ("<child>a</child>", sb.ToString (), "#1");
}
示例2: ReadCharsNested
[Test] // bug #80308
public void ReadCharsNested ()
{
char[] buf = new char [4];
string xml = "<root><text>AAAA</text></root>";
string [] strings = new string [] {
"<tex", "t>AA", "AA</", "text", ">"};
XmlTextReader r = new XmlTextReader (
xml, XmlNodeType.Document, null);
int c, n = 0;
while (r.Read ())
if (r.NodeType == XmlNodeType.Element)
while ((c = r.ReadChars (buf, 0, buf.Length)) > 0)
Assert.AreEqual (strings [n++], new string (buf, 0, c), "at " + n);
Assert.AreEqual (5, n, "total lines");
}