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 want to use Blender as my level designer tool for an XNA game. Using an existing plugin, I can export my levels to DotScene format which is basically an xml file like this one:

<scene formatVersion="1.0.0">
  <nodes>
    <node name="scene-staircase.001">
      <position x="10.500000" y="1.400000" z="-9.600000"/>
      <quaternion x="0.000000" y="0.000000" z="-0.000000" w="1.000000"/>
      <scale x="1.000000" y="1.000000" z="1.000000"/>
      <entity name="scene-staircase.001" meshFile="staircase.mesh"/>
    </node>

    <node name="Lamp.003">
      <position x="11.024290" y="5.903862" z="9.658987"/>
      <quaternion x="-0.284166" y="0.726942" z="0.342034" w="0.523275"/>
      <scale x="1.000000" y="1.000000" z="1.000000"/>
      <light name="Spot.003" type="point">
        <colourDiffuse r="0.400000" g="0.154618" b="0.145180"/>
        <colourSpecular r="0.400000" g="0.154618" b="0.145180"/>
        <lightAttenuation range="5000.0" constant="1.000000" linear="0.033333" quadratic="0.000000"/>
      </light>
    </node>

    ...

  </nodes>
</scene>

Using naming conventions I could easily parse the file and load the correspondent in game content. I am new to XNA and I have seen that there are several methods to load XML files into a game like serializing and deserializing. Which one would you recommend?

share|improve this question
1  
I realized I can add my XML files as resources to the Content Manager specifying I don't want any binary conversion to take place and I want the files to get copied. Then, I can load the XML files as in a normal C# program. –  David Saltares Márquez Nov 29 '11 at 15:15
    
If that's an answer you should put it in the answer section so that you can "accept" it and the question doesn't get bumped up because it's "unanswered". –  Tetrad Nov 29 '11 at 16:01
    
Done, I can't accept my answer as valid until tomorrow though. –  David Saltares Márquez Nov 29 '11 at 23:16

2 Answers 2

up vote 1 down vote accepted

I would actually recommend using the newer XDocument class instead of XmlDocument. Check:

http://stackoverflow.com/questions/1542073/xdocument-or-xmldocument

According to that thread it's also compatible with XBox and WP7, but I haven't tried since I'm currently developing for Windows.

share|improve this answer

I realized I can add my XML files as resources to the Content Manager specifying I don't want any binary conversion to take place and I want the files to get copied. Then, I can load the XML files as in a normal C# program:

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Content.RootDirectory + "\\XML\\file.xml");
share|improve this answer
    
Does this work on Xbox or WP7? –  Nate Nov 29 '11 at 23:40
2  
The answer is yes to both –  ClassicThunder Nov 30 '11 at 1:41
    
Another option, is to create a custom content processor, which might be worth it, but is more involved. –  George Duckett Nov 30 '11 at 15:53
    
The problem here is the loss of compression without the binary conversion. –  Sinthia V Jul 4 '12 at 18:04

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.