I'm trying to work through the XNA tutorial on using XML files with the content pipeline, but I keep running into trouble. All I'm getting is a relatively blank XML file:
<?xml version="1.0" encoding="utf-8"?><XnaContent> <Asset Type="BlockPipeline.BlockPipelineContent" /></XnaContent>
using System.Xml;using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate;namespace BlockPipeline{ class TempMain { public static void Main() { BlockPipelineContent testBlock = new BlockPipelineContent(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; using (XmlWriter xmlWriter = XmlWriter.Create("testSettings.xml", settings)) { IntermediateSerializer.Serialize(xmlWriter, testBlock, null); } } }}
using System;using System.Collections.Generic;using System.Text;using Microsoft.Xna.Framework;using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;using Microsoft.Xna.Framework.Graphics;namespace BlockPipeline{ [ContentTypeWriter] class BlockSettingsWriter : ContentTypeWriter { protected override void Write(ContentWriter output, BlockPipelineContent value) { output.Write(value.getPosition()); output.Write(value.getMySpriteString()); output.Write(value.isSolid()); output.Write(value.getZ()); } public override string GetRuntimeType(TargetPlatform targetPlatform) { return "Extinctathon.Block, Extinctathon"; } public override string GetRuntimeReader(TargetPlatform targetPlatform) { return "Extinctathon.BlockReader, Extinctathon"; } } }
5/20/2008 10:53:10 AM
um n/m. hold up. let me have a look[Edited on May 20, 2008 at 11:01 AM. Reason : .]
5/20/2008 11:00:23 AM
I'm not familiar with:[ContentTypeWriter] class BlockSettingsWriter : ContentTypeWriterI typically use-> XmlDocumentand add -> XmlNode nodes to it.just add an xml file to your content or a folder somewhere and pass it that location and add/subtract from it as you with using those classes
5/20/2008 11:18:00 AM
i'm not familiar with XNAbut looking at the code, i don't see why the BlockSettingsWriter Write method would be called. your Main() doesn't use a BlockSettingsWriter object[Edited on May 20, 2008 at 12:45 PM. Reason : per the this part SHOULD be called comment]
5/20/2008 12:45:08 PM
Yeah...like I said, I don't at this point understand the actual flow of the program. However, this is the method that is given in Microsoft's XNA tutorials, but of course that whole site is down at the moment.HRM.
5/20/2008 12:51:32 PM
lulz, they totally revamped/relaunched the XNA site totay and as far as I can tell the tutorial I was working from is no longer a part of the site
5/20/2008 3:45:01 PM
5/20/2008 3:55:12 PM
For anybody who cares to know, for some reason, although the tutorial I was using tells you how to write the ContentTypeWriter, it apparently doesn't really use it (or something).Any public members of the class will be written to the XML file. I changed the neccessary members to public and that now works. Going to XNA forums for the rest
5/20/2008 5:03:47 PM
Also, FWIW, the purpose of using the custom ContentTypeWriter/Reader is so that you can add XML files to your project which are converted to XMB (i.e. binary XML files) at compile time for teh speed boosts and whatnot.
5/20/2008 6:52:32 PM