Saturday, June 8, 2013

[Rails] Re: Re: Why Nokogiri::HTML::Document#meta_encoding returns nil ?

Tamara Temple wrote in post #1111725:
> Love U Ruby <lists@ruby-forum.com> wrote:

> irb(main):027:0> doc = Nokogiri::HTML::Document.parse "<title> Save the
> page! </title>"
> #<Nokogiri::HTML::Document:0x4c2aa20 name="document"
> children=[#<Nokogiri::XML::DTD:0x4c35fc4 name="html">,
> #<Nokogiri::XML::Element:0x4c35a38 name="html"
> children=[#<Nokogiri::XML::Element:0x4c3565a name="head"
> children=[#<Nokogiri::XML::Element:0x4c35470 name="title"
> children=[#<Nokogiri::XML::Text:0x4c35196 " Save the page! ">]>]>]>]>
> irb(main):028:0> puts doc
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
> "http://www.w3.org/TR/REC-html40/loose.dtd">
> <html><head>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
> <title> Save the page! </title>
> </head></html>
> nil
> irb(main):029:0> doc.meta_encoding
> "UTF-8"
> irb(main):030:0> doc.meta_encoding="ISO-8599-2"
> "ISO-8599-2"
> irb(main):031:0> doc.meta_encoding
> "ISO-8599-2"

For me why things not working,I don't know :

[1] pry(main)> require "nokogiri"
=> true
[2] pry(main)> doc = Nokogiri::HTML::Document.parse "<title> Save the
page! </title>"
=> #(Document:0x46ca5da {
name = "document",
children = [
#(DTD:0x46beef6 { name = "html" }),
#(Element:0x46be1c2 {
name = "html",
children = [
#(Element:0x46b5158 {
name = "head",
children = [
#(Element:0x46b4974 {
name = "title",
children = [ #(Text " Save the page! ")]
})]
})]
})]
})
[5] pry(main)> doc.meta_encoding
=> nil
[6] pry(main)> doc.meta_encoding="ISO-8599-2"
=> "ISO-8599-2"
[7] pry(main)> doc.meta_encoding
=> nil
[8] pry(main)>

--
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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c4d6a9dfa816d6391e42aec3d3795e3a%40ruby-forum.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate