Saturday, 11 December 2010

This works:


import System
import System.IO
import System.Xml
import System.Xml.Serialization

src = """
<scene name="start" default="waking_up" desc="in which ..." >
 <narrative name="waking_up" desc="it all starts here">
  <snippet>
        Look, we've been throught this a dozen times.
  </snippet>
  <snippet>
        Not wishing to hurry you or anything, but ...
  </snippet>
  <snippet>
        When do we get to the sex?
  </snippet>
 </narrative>
</scene>
"""
def patt(r as XmlReader, s as string):
        r.MoveToAttribute(s)
        print "${s}=${r.Value}"

Allowing for some whitespace handling, that should let me read this stuff back in again. Now I just need to re-write my save and load functions :)

I'll need to test handling for things like embedded apostrophes, too. Hopefully the XmlReader/Writer code will take care of entity conversion for me

No comments: