Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm using the Content.Load() mechanism to load core game definitions from XML files. It works fine, though some definitions should be editable/moddable by the players. Since the content pipeline compiles everything into xnb files, that doesn't work for now.

I've seen that the inbuild XNA Song content processor does create 2 files. 1 xnb file which contains meta data for the song and 1 wma file which contains the actual data. I've tried to rebuild that mechanism (so that the second file is the actual xml file), but for some reason I can't use the namespace which contains the IntermediateSerializer class to load the xml (obviously the namespace is only available in a content project?).

How can I deploy raw, editable xml files and load them with Content.Load()?

share|improve this question
1  
Hi @xnanewb, and welcome to GDSE. Since your question is already tagged with xna, you don't also need to dump the tag in your title - I've edited it out. –  Jonathan Hobbs Nov 8 '12 at 11:08
add comment

3 Answers

You don't. Content is for loading objects compiled by the content processor. However, you can add the xml files to the content project and have the project copy them to the deploy location without compiling them. If you do this you can use relative paths to access the content.

To do so put the XML file in your project as you normally would, change Content Processor to No Content Required, and then change Copy to Output Directory to Copy if Newer.

Then you can load the xml as you normally would XmlTextReader(@"Content\example.xml");.

share|improve this answer
add comment

On Xbox and Windows Phone you can only use the content pipeline. Everything gets serialized to XNB files and only the those are available on those machines. I don't think there is a special case for audio there and besides there is no way for the users to mod the files on Windows Phone and Xbox anyway.

However on the PC you can use all the .NET classes and more. So you can just load raw xml files using the classes from the System.XML namespaces. For example by using XmlDocument.Load.

share|improve this answer
    
That's not true. You can load XML files and textures without having to go through the Content pipeline on the Xbox and phone using XmlDocument.Load. As long as your asset is in your project and set to copy to the output directory the file will be available to be read like any other file. You still won't be able to mod them, so you would need to make a copy in the user's isolated storage for that. –  dadoo Games Nov 8 '12 at 14:27
    
I've just created an empty XNA 4 Xbox 360 project, added a reference to System.XML and the XmlDocument class was not available. So I don't see how that is possible. –  Roy T. Nov 8 '12 at 16:16
    
XmlDocument worked for XNA 3.1 and earlier. XNA 4 uses many Silverlight assemblies, so you need to use XDocument instead (msdn.microsoft.com/en-us/library/…) but the ability to load XML outside the content pipeline remains. –  dadoo Games Nov 8 '12 at 16:29
    
But that would mean I would have to parse out the xml elements manually, right? IntermediateSerializer does just that automatically.I figured why the namespace is not available. One has to select the full .net profile for the project and not just the pre-configured client-profile. –  xnanewb Nov 9 '12 at 20:28
3  
Note that the full .net profile is not available on the Xbox and WP! –  Roy T. Nov 10 '12 at 8:46
show 1 more comment

Store the user data in a different place like you want...

You can save a copy of the loaded data or only the modifications made...

When the user get into the game next time check if exist that copy or modification, use it else load the default raw data through content load.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.