XMLWriter vs XMLDictionaryWriter

前端 未结 2 420
忘了有多久
忘了有多久 2021-01-04 01:30

What\'s the difference between XMLWriter and XMLDictionaryWriter? In which cases is each one generally used?

2条回答
  •  再見小時候
    2021-01-04 02:21

    XmlWriter is an abstract class used for writing XML documents in a forward-only manner. You use the static Create method to create concrete implementations of the class for use. This method of creating XML documents is useful when you need to quickly create arbitrary XML for whatever use.

    XmlDictionaryWriter is an abstract class used for serialization and deserialization of objects to and from XML. From what I understand, it is used in WCF for serializing objects for moving across the wire. XmlDictionaryWriter can serialize using binary, text or MTOM formats. I would expect you would only use this class if you were specifically needing custom (de)serialization for use over WCF. See also here.

    Hope that helps.

提交回复
热议问题