SIXX works very good to write/read objects, but it means you have to give up on your own xml schema. And it's almost to easy to use: sws := SixxWriteStream newFileNamed: aFileName. sws nextPut: (self objectsToExport). sws close. srs := SixxReadStream readOnlyFileNamed: (aFileName). objects := OrderedCollection new. [srs atEnd] whileFalse: [objects add: srs next]. srs close. On 21 Feb 2011, at 10:11, stephane ducasse wrote:
Hi guys
I often encounter the following situation: I have an xmldoc and I want to load it and get the corresponding objects. Here is an example
<group> <groupName>Test2Cards</groupName> <cards><card> <cardName>All Is Dust</cardName> <manaCost>7</manaCost> <convertedManaCost>7</convertedManaCost> <type>Tribal Sorcery â Eldrazi</type> <cardText>Each player sacrifices all colored permanents he or she controls.</cardText> <rarity>mythic</rarity> <cardNumber>1</cardNumber> <artist>Jason Felix</artist> <kind>STD</kind> <expansionId>ELDRAZI</expansionId> </card> <card> <cardName>Kird Ape</cardName> <manaCost>G</manaCost> <convertedManaCost>1</convertedManaCost> <type>Tribal Sorcery â Eldrazi</type> <cardText>get +1/+1 when you control</cardText> <rarity>common</rarity> <cardNumber>33</cardNumber> <artist>Zork</artist> <kind>STD</kind> <expansionId>WORLDWAKE</expansionId> </card></cards> </group>
I have card and group. But I could have several kind of nodes. So I was wondering if there are patterns to read in and map that to objects. In the future I would like to have magritte like type of first class instance variables that perform i/o in xml or other formats because this is always the same.
stef