   Why should I use XML?
  I've been using XML for a while now, but lately I've been getting a feeling that I would be as good if not better by serializing my data in binary instead of strings.I mainly use XNA and in all of the examples found on the web, I see people using XML to save data, thats why I started XNA programming using XMLBut now Im almost decided on using binary serialization, some Im looking some reassurance from you guys about the choice Im about to take.Thanks!   
  For XNA games in particular XML is useful because it's a widely-used standard, and it produces human-readable output.  The XML serialization functionality in the .NET Framework is also available on both the PC and the Xbox 360, which is pretty important for a lot of XNA developers (binary serialization is on the PC only).   ;  Really? are you sure about this?? even If one could write a custom content importer for such data?What weird choice not to support other kinds of serialization on the xbox, wouldnt it be faster to load binary data instead of string parsing?Well at least now I have reasons to keep using XML, because personally I really dont care that much for being able to read my data files with a text editor since I tend to write editors for every single piece of data my games need.Thanks a lot for the insight   ;  I'm talking about at runtime.  So for instance if you wanted to save a file containing high scores, you could use XmlSerializer but not BinaryFormatter to do it on the Xbox 360.  You can go ahead and look at the documentation yourself if you'd like: none of the members have the XNA logo indicating they are usable one the 360 (in fact they're not supported by the .NET CF at all).If you're talking about data that's being run through the content pipeline, that's a different issue.  Since your importer and processor run on the PC, you can use whatever format you want.  However you may still want a human-readable format like XML, especially since the content will be converted to a binary format so that it can be loaded quickly at runtime.   ;  XML is mostly about human readability, not speed (in fact, it's very slow). XML gives you great flexibility, it can be used for just about any data serialization scenario while allowing one to freely and manually modify the files.   ;Quote:Original post by TriggerBXML is mostly about human readability, not speed (in fact, it's very slow). XML gives you great flexibility, it can be used for just about any data serialization scenario while allowing one to freely and manually modify the files.You got the second half right: XML is for flexibiity and interoperability (different systems, different OSes, different endianess - same file).XML is not supposed to be human-readeable / writable. You *can* write an XML file by hand, but frankly:1. it's a form of masochism and2. how many times have you needed to do that?(Myself: just once, for a build script. Even so, I started by copying it from another project and modifying a few values).   ;Quote:Original post by TriggerBXML is mostly about human readability, not speed (in fact, it's very slow).Tbh, I am of the fraction that says "XML is binary data", as in "not human readable", for some small, but deciding reasons. E.g., as a more or less experienced programmer, you know that you have to write &lt; instead of < inside value regions, but a novice could easily break the whole file when he doesn't know that. So, a file of XML looks like text, and you can edit it like text when you are careful, but like binary data, you can break it easily. Admittedly, most text formats are, following that argumentation, binary data, too, but then they often have a more ovbvious and recoverable structure (like "width: 1234 \n").That doesn't mean I don't like XML, indeed it is an easy way to save hierarchical data, without the need to fall back to a 'full' binary solution which is unportable and heavy to conserve over time and amongst operating systems and - generations. E.g., even if the underlying application loses all maintainers and it dies a lonely death, you can still recover your data from text- or mostly-text-formats and import it into other apps.   ;  I like XML because you can find an importer and exporter for almost every language.  If I create an XML file in .NET, I know I can easily read it again from a PHP script.  File parsers are extremely boring to write and maintain.Also, I would consider XML as a mostly-human readable format, because (properly named) elements and attributes are somewhat self documenting.  In an ideal world all file formats would come with proper documentation, but in reality that doesn't happen.  You can also tweak files with a text editor without having to write an entire editor.   ;Quote:Original post by EvilNandoI've been using XML for a while now, but lately I've been getting a feeling that I would be as good if not better by serializing my data in binary instead of strings.I'd say that unless you have a solid reason for wanting to switch away from XML that isn't just an urge or "feeling", then you should stick with it.  You're already using XML, everything works (presumably), and you really shouldn't spend another minute dwelling on the issue.  This isn't about text versus binary, but rather about solving problems and moving on.  It sounds like you've already solved the serialization problem for your application.  Until serialization becomes a problem again, I'm sure there are other parts of your application you haven't solved/finished yet that need attention [smile]   ;  I wouldn't switch, though I'm not using XML in my projects, because of its poor human-readability, and especially human-writability. My current format looks like this// comment/*multiline comment*/display{  custom_res_x=800;  custom_res_y=600;  fullscreen=0;  no_vsync=0;  video_mode=0;}game{  arena=27;  difficulty=0;Structure: blocks can be nested. Anything between = and ; is read as value, with \; if you want to pass literal ;. \\ to pass \ , and so on.Extremely easy to parse into a tree in any language, and not so verbose as to be pain to type.There exist zillion of poorly convertible ways how same data can be written in XML, so it's not much more of 'data standard' than ASCII or Binary are 'data standards'. (<key>keyname</key><value>1234</value>  versus <keyname>1234</keyname> versus <keyname value="1234" /> just to list a few common styles). A particular XML format, like, for example, ODT, is a data format; but XML itself is not.[Edited by - Dmytry on May 27, 2009 4:27:10 AM]