How do I transform XML into a binary file with some structure? I want to use XSLT, but this tehnology can not be used to convert xml to binary files.
What tehnology is acceptable for this problem?
How do I transform XML into a binary file with some structure? I want to use XSLT, but this tehnology can not be used to convert xml to binary files.
What tehnology is acceptable for this problem?
That depends largely on what exactly the binary looks like ;p Xslt is not going to help much here; I would be using either a dedicated c# method that understands the structure (if it is specific to one task), or if a general purpose approach is needed (i.e. to cater for more than one scernario), then a proper serialization library to match your intended format.
You should be prepared to spend lots of time working with streams, buffers and encoders.
If you just want to serialize, and you don't care about the format - then use a pre-canned serializer; I suggest protobuf-net, as it works nicely alongside XmlSerializer allowing you to read from xml and write as binary, or read from binary and write as xml, etc. Likewise, since it is (by default) tree-based it has a direct correlation to xml (also tree-based).
If your data is not xml serialized then I would use an xml reader to read the data, create a strong typed class to represent your data then serialize it to binary, so when you read it back all you have to do is deserialize your binary file and cast it back to your orginal strongly typed class.