IFragmentCapableXmlDictionaryWriter.WriteFragment Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Writes an XML fragment to the underlying stream of the writer.
public:
void WriteFragment(cli::array <System::Byte> ^ buffer, int offset, int count);
public void WriteFragment (byte[] buffer, int offset, int count);
abstract member WriteFragment : byte[] * int * int -> unit
Public Sub WriteFragment (buffer As Byte(), offset As Integer, count As Integer)
Parameters
- buffer
- Byte[]
The buffer to write to.
- offset
- Int32
The starting position from which to write in buffer
.
- count
- Int32
The number of bytes to be written to the buffer
.
Examples
MemoryStream stream = new MemoryStream();
MemoryStream fragmentStream = new MemoryStream();
XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream);
IXmlFragmentCapableXmlDictionaryWriter fragmentWriter = writer as IXmlFragmentCapableXmlDictionaryWriter;
if (fragmentWriter == null || !fragmentWriter.CanFragment)
{
Console.WriteLine("This writer doesn't support fragments");
return;
}
writer.WriteStartElement("Root");
fragmentWriter.StartFragment(fragmentStream, false);
writer.WriteStartElement("Body");
writer.WriteString("This is my body");
writer.WriteEndElement();
fragmentWriter.EndFragment();
writer.WriteStartElement("CharsInTheBody");
writer.WriteValue(fragmentStream.Length);
writer.WriteEndElement();
fragmentWriter.WriteFragment(fragmentStream.GetBuffer(), 0, (int)fragmentStream.Length);
writer.WriteEndElement(); // Root
Remarks
Writes a fragment captured between StartFragment
and EndFragment
and calls back into the XmlDictionaryWriter's main stream. The fragment written is count
bytes starting at the index offset
from the supplied buffer
. The behavior is undefined if the supplied fragment was not captured using this writer instance.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기