user310291
user310291

Reputation: 38228

openxml option to be fully in text format?

I have tried to generate "Hello World" with openxml sdk. To my surprise when trying to open the xml document it was not purely text format but it contains some ugly binary stuff.

Is there any option to have text format when the content is only text ?

I can't see any rationale for the binary part if it is supposedly "open".

Update: my mistake I didn't know docx was just a zip file. If I unzip it I will get the open xml format. So Openxml is really open.

Upvotes: 2

Views: 229

Answers (2)

Lucero
Lucero

Reputation: 60276

The OpenXML format is an archive file (ZIP to be exact) with XML metadata and XML as well as binary contents.

This makes sense since it is pretty inefficient to include binary data, such as images, sounds, embedded objects etc. in textual XML. The "open" in the name comes from MS marketing and because the format is standardized and well documented.

Have a look at the System.IO.Packaging namespace, you'll find everything you need to create, read and modify OpenXML packages.

Upvotes: 2

Oded
Oded

Reputation: 499302

OpenXML is not pure text. If your file is pure text, save it as a text file.

This can be done via System.IO.File.WriteAllText.

Upvotes: 1

Related Questions