Hi I was browsing fixes in squeak and I saw http://code.google.com/p/pharo/issues/detail?id=2822 May be this can help to improve the XML package. Stef Fix printing of XMLElements; add tests for behavior. =============== Diff against XML-Parser-mtf.30 =============== Item was added: + ----- Method: XMLParserTest>>testPrintElements (in category 'tests') ----- + testPrintElements + | node | + node:= (XMLElement new) name: 'foo'; + setAttributes: (Dictionary new); + yourself. + self assert: node asString withBlanksTrimmed = '<foo/>'. + + node:= (XMLElement new) name: 'foo'; + setAttributes: (Dictionary newFromPairs: {'id'. '123'}); + yourself. + self assert: node asString withBlanksTrimmed = '<foo id="123"/>'. + + node:= (XMLElement new) name: 'foo'; + addContent: (XMLStringNode string: 'Hello World'); + setAttributes: (Dictionary new); + yourself. + self assert: node asString withBlanksTrimmed = '<foo>Hello World</foo>'. + + node:= (XMLElement new) name: 'foo'; + addContent: (XMLStringNode string: 'Hello World'); + setAttributes: (Dictionary newFromPairs: {'id'. '123'}); + yourself. + self assert: node asString withBlanksTrimmed = '<foo id="123">Hello World</foo>'. + + ! Item was changed: ----- Method: XMLElement>>isEmpty (in category 'testing') ----- isEmpty + "Answer true if the receiver is empty" + + ^self elementsAndContents isEmpty! - ^self elements isEmpty! Item was changed: ----- Method: XMLElement>>printXMLOn: (in category 'printing') ----- printXMLOn: writer + "Print the receiver in XML form" + writer startElement: self name attributeList: self attributes. (writer canonical not + and: [self isEmpty]) - and: [self isEmpty and: [self attributes isEmpty not]]) ifTrue: [writer endEmptyTag: self name] ifFalse: [ writer endTag. self elementsAndContentsDo: [:content | content printXMLOn: writer]. writer endTag: self name]!