How to fix IFragmentCapableXmlDictionaryWriter.WriteFragment example

Nicholas Piazza 536 Reputation points
2024-06-20T16:12:32.92+00:00

In the Microsoft documentation for System.Xml, there is an example for IFragmentCapableXmlDictionaryWriter.WriteFragment at URL https://learn.microsoft.com/en-us/dotnet/api/system.xml.ifragmentcapablexmldictionarywriter.writefragment?view=net-8.0. When I implement that example, it always takes the path that leads to the WriteLine message "This writer doesn't support fragments." How can that example be rewritten to support fragment writing so I can see how it is actually supposed to work?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,548 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 114K Reputation points
    2024-06-20T16:51:24.3766667+00:00

    Probably the example is for .NET Framework.

    Try another writer:

    XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter( stream );