Nokogiri/Ruby array question -


i have quick question. writing nokogiri/ruby script , have following code:

fullid = doc.xpath("/success/data/annotatorresultbean/annotations/annotationbean/concept/fullid") fullid.each |e|             e = e.to_s()             g.write(e + "\n")     end 

this spits out following text:

<fullid>d001792</fullid> <fullid>d001792</fullid> <fullid>d001792</fullid> <fullid>d008715</fullid> 

i wanted numbers text in between "< fullid>" saved, without < fullid>,< /fullid> markup. missing?

bobby

i think want use text() accessor (which returns child text values), rather to_s() (which serializes entire node, see here).

i'm not sure g object you're calling write on is, following code should give array containing of text in fullid nodes:

doc.xpath(your_xpath).map {|e| e.text} 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -