XML-files
Cees De Groot
cdegroot at gmail.com
Sat Nov 26 23:07:00 UTC 2005
On 11/26/05, Marcus Pedersén <marcus.pedersen at comhem.se> wrote:
> I want to get the info from a simple XML-file and use it in the system to
> get strings from each tag.
I snipped a method from my SqueakPeople package which I hope serves as
illustration (package available on Squeak Source)
Hth,
Cees
fromXml: aByteString
| projDir file answer doc info info2 |
projDir := (FileDirectory default directoryNamed: 'proj')
directoryNamed: aByteString.
file := projDir readOnlyFileNamed: 'info.xml'.
file ifNil: [^nil].
[answer := self new.
doc := XMLDOMParser parseDocumentFrom: file]
ensure: [file close].
answer projectName: aByteString.
info := doc elementAt: 'info'.
info2 := info elementAt: 'info'.
answer
creationDate: (info elementAt: 'cdate') contentString;
url: (info2 attributeAt: 'url');
squeakMapUrl: (info2 attributeAt: 'smurl');
license: (info2 attributeAt: 'license');
notes: (info2 attributeAt: 'notes');
creator: (info2 attributeAt: 'creator');
locked: (info2 attributeAt: 'locked') = 'yes'.
file := projDir fileNamed: 'staff-name.xml'.
file ifNotNil: [
[doc := XMLDOMParser parseDocumentFrom: file.
self fillProjectRelationsInNew: answer from: doc]
ensure: [file close]].
^answer
More information about the Squeak-dev
mailing list
|