[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] XML usage question..
From: |
Paolo Bonzini |
Subject: |
Re: [Help-smalltalk] XML usage question.. |
Date: |
Tue, 25 Sep 2012 18:56:29 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 |
Il 25/09/2012 18:51, Rick Flower ha scritto:
> buildUseCaseCollectionFrom: aList [
> aList detect: [:each | Transcript show: 'Element:' , (each
> characterData); cr ]
> ]
>
> stream := './requirements.xml' asFile readStream.
> parser := XML.XMLParser new.
> parser validate: false.
> parser parse: stream.
>
> docroot := parser document root.
> self buildUseCaseCollectionFrom: (docroot elementsNamed: 'UseCases').
>
> ==============================================================
>
> When I run it, I get the following output -- seems
> like the Collection of Use-Case Elements is not
> quite right.. I was expecting two "Element:" lines
> each with the respective Use-Case # element but not
> both bunched up as a single.. Any ideas on what I've
> messed up?
>
> Element:
> Use-Case #1
> Use-Case #2
#detect: is not doing what you want. It returns the first element for
which the block returns true. Note that your block does not return a
boolean in the first place.
I think this is returning all the character-data inside the <UseCases>
element, discarding the elements.
Paolo