Hello Guys
I'm new in Ruby and now I'm trying to type my first app
now i have SVG file contain rows such as
<text x="10" y="20"
style="font-family: Helvetica;
font-size : 24;
fill : #ff0000;
stroke : #000000;">First label</text>
<text x="85" y="150"
style="font-family: Helvetica;
font-size : 24;
fill : #ff0000;
stroke : #000000;">Second label</text>
now when i want to get the labels form the file
i was used non professional way to get them
buy using this code
f=File.open(@svgFile)
@data=Nokogiri::XML(f)
@data=@data.to_s # convert to string
@data=@data.split('<text')[1..-1] # convert to array and remove
first
element
f.close
<% @data.each do |data|%>
<% @data=data.gsub(%r{</?[^>]+?>},'') %>
<% @data=data.split('>')[1][0..-7]%>
<%= @data %><br>
<% end%>
so now if i want to get the full data to every element such as
name= First label
stroke =#000000
font-size=24
how i can get the child data in the svg file with professional code
i don't like the way to remove html tags to get the data ???
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/75197fadafae4ba0ccd20bfa1a7b5c0a%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.