Filter Array

hihi, can i ask if

how can i filter an Array using ruby?

i have this xml doc with these datas
a
b
c

this is my code

invisibility = XPath.first( doc, “//lm:landmark” )
XPath.each( doc, “//lm:name”) { |element| puts element.text }
names = XPath.match( doc, “//lm:name” )
puts names

so how am i gonna filter out the

and it jus shows me a instead of the tags too? pls i really need help
urgently…

help me pls~~~~~~~~

im struggeling…T.T

wow thx fred for helping me~~~ i got my things work now!!!

really appreciate ur help!!!

if u don mind can pm me ur contact so i can ask u question if i have
problem??

hehe… if cant its alright~~~

cause im really new to ruby but need to start creating application using
these ruby… ehhe…

anyway thx alot

On Jun 3, 10:01 am, loki ja [email protected] wrote:

invisibility = XPath.first( doc, “//lm:landmark” )
names = XPath.each( doc, “//lm:name”) { |element| puts element.text }

You probably meant something like
names = []
XPath.each ( doc, “//lm:name”) { |element| names << element.text }

In your code the block does nothing apart from output the text - the
return value is just the collection iterated over.

Fred

invisibility = XPath.first( doc, “//lm:landmark” )
names = XPath.each( doc, “//lm:name”) { |element| puts element.text }

puts names

jus split the string is enough… how…~~~

it’s better posting on the mailing list because if someone else has a
similar problem, they may google it and find it.
On Wed, Jun 4, 2008 at 11:10 AM, loki ja
[email protected]
wrote:

cause im really new to ruby but need to start creating application using
these ruby… ehhe…

anyway thx alot

Posted via http://www.ruby-forum.com/.


Appreciated my help?
Recommend me on Working With Rails
http://workingwithrails.com/person/11030-ryan-bigg