Best format for wpf text file [closed] - c#

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Which of yaml, html, xml, json etc, is best suited for large text blocks and formatting (headings, paragraphs, italics etc)? Also taking into account that it's for use in a wpf app.

Considering the fact that standards such as Office Open XML or XPS use XML to store large documents, I'd suggest XML is likely the best choice.
If you look at some of the document choices for WPF, you will see that XML is a natural choice. Whatever you represent in XAML is XML. A FlowDocument can be serialized to XML as well (see this answer).
You will find further information here.

Related

How to create a file format for a custom application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I currently have an application written in C#, which performs some calculations on electrical lines sag and tensions.
The program has only the option of exporting a .doc file, or printing to PDF. As it stands, I cannot save it into a format that allows me to change any data, as it is already in word, or pdf.
i need to setup an intermediary file format, that allows editing of the file, while retaining the ability to export the project file to Word or PDF.
Thank you in advance.
You'll have to define your own binary file format. How to define it depends on the data to store and this is up to you.
Or you can use XML file format. Of course again you'll have to define what to write in which structure to the file. It might be a good idea to provide your own DTD.

Which one is best? convert datatable to json or xml? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I create two projects using dot net. I send some data from one project to another project. I already handled this using xml conversion. Now I think to convert this using json data. Which one is best?.
In most cases, json is better. Because it has less redundant text and more efficient to parse. And what's more, is's much easier to parse json in javascript so that building a web app is much more convenient.
On the other hand, XML is more readable than json. That might be the only advantage of XML in this case.
XML is more verbose, but in the other hand is pretty easy to read.
JSON is simpler but not so good to read.
If you will not have humans looking the data, maybe using JSON would be a better idea. Since its smaller and will be less of a burden in your network (If that is a problem).
The other way you could evaluate, is looking on serialization speed, and that will depend a lot on the library you are using.

Better way to load a XML [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am reading a XMl and using it for some processing in my application.
var config = XElement.Load("c:/sample.xml");
Is there anyway to do load it in a better way? it takes a while while trying to process this line of code.
Look at XmlReader class, it provides fast, noncached, forward-only access to XML data.
You use so call DOM model of loading document which loads the whole XML. An alternative is a SAX model when you read data in consecutive manner. The API for that is XmlReader

Deserialize an XML file without loading it all in the memory [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 months ago.
Improve this question
Suppose that your application serializes objects using XmlSerializer. When another part of the application (e.g. an external service or another component) process that XML file, gets you back a huge XML file that is a serialization of a huge object.
Which are your approach in deserializing and processing that response without filling your server's memory?
I usually prefer to use the XmlSerializer, but when I have to fight against these monster, I have no bullet-proof solutions. I've read about XNode.ReadFrom, but I'm wondering if using this method I can accomplish like a streaming-deserialization.

C# Parsing Best Practices [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need to parse some known file formats, one of them is the CUSCAR format, i strongly believe that RegEx will do the job ,any suggestions ?
I just looked at the CUSCAR spec, and I think you'll get some pretty ugly regex code to parse that. You could get away with it, if you are parsing only part of it. You'll have to test for speed, as your main bottleneck will be I/O.
I did something similar with the vendor files that came from QWEST. These beasties were hierarchical text files. Parsing those sucked! I'm currently creating and parsing text files between 4 to 50 million lines each (every day).
There is a nice framework called FileHelpers Library. This framework will help you create object-oriented representation of the records (text lines). It even has a nice wizard to walk you through the creation of these objects representing the records. It will handle master-detail, delimited, and fixed formats easily.

Categories