Ruby 2.6.0 リファレンスマニュアル > ライブラリ一覧 > rexml/documentライブラリ > REXML::Instructionクラス > content

instance method REXML::Instruction#content

content -> String | nil[permalink][rdoc]

XML 処理命令の内容を返します。


require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/css" href="style.css"?>
<?foobar?>
<root />
EOS
doc[2] # => <?p-i xml-stylesheet ...?>
doc[2].target # => "xml-stylesheet"
doc[2].content # => "type=\"text/css\" href=\"style.css\""
doc[4].target # => "foobar"
doc[4].content # => nil