[Pharo-project] XMLWriter question

Stéphane Ducasse stephane.ducasse at inria.fr
Mon Feb 21 09:58:48 CET 2011


Hi guys

I have a question about XMLWriter. I have cards and group of cards.
Each class know how to serialize itself.

For card I have xmlOn: (one of my methods) that describes the card attributes

Card>>xmlOn: aWriter
	"write a description of the receiver properties as xml uing aWriter, an instance of XMLWriter"
	
	aWriter tag
		name: #card;
		with: [self xmlInstVarOn: aWriter]
	

Group>>xmlOn: aWriter
	"write a description of the receiver properties as xml uing aWriter, an instance of XMLWriter"
	
	| cardWriter |
	cardWriter := XMLWriter new.
	cards do: [:each | each xmlOn: cardWriter].
	
	aWriter tag
		name: #group;
		with: [ 
			aWriter tag: #groupName with: self groupName.
			aWriter tag: #cards with: [ aWriter raw:  cardWriter contents]]
	
	
And I'm not really happy. Because I would like to avoid to use raw: and instantiate a new writer.

I would like to know how I could use the write to pass the results of the iteration over cards
I wanted to write something like

	aWriter tag
		name: #group;
		with: [ 
			aWriter tag: #groupName with: self groupName.
			aWriter tag: #cards with: [self cards do: [:each | each xmlOn: aWriter]]











More information about the Pharo-project mailing list