4
\$\begingroup\$

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()?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Nov 8, 2012 at 11:08

3 Answers 3

3
\$\begingroup\$

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");.

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
6
  • \$\begingroup\$ 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. \$\endgroup\$ Nov 8, 2012 at 14:27
  • \$\begingroup\$ 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. \$\endgroup\$
    – Roy T.
    Nov 8, 2012 at 16:16
  • \$\begingroup\$ 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. \$\endgroup\$ Nov 8, 2012 at 16:29
  • \$\begingroup\$ 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. \$\endgroup\$
    – xnanewb
    Nov 9, 2012 at 20:28
  • 3
    \$\begingroup\$ Note that the full .net profile is not available on the Xbox and WP! \$\endgroup\$
    – Roy T.
    Nov 10, 2012 at 8:46
0
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .