new(arg, respect_whitespace=false, parent=nil, raw=nil, entity_filter=nil, illegal=NEEDS_A_SECOND_CHECK ) public

Constructor arg if a String, the content is set to the String. If a Text, the object is shallowly cloned.

respect_whitespace (boolean, false) if true, whitespace is respected

parent (nil) if this is a Parent object, the parent will be set to this.

raw (nil) This argument can be given three values. If true, then the value of used to construct this object is expected to contain no unescaped XML markup, and REXML will not change the text. If this value is false, the string may contain any characters, and REXML will escape any and all defined entities whose values are contained in the text. If this value is nil (the default), then the raw value of the parent will be used as the raw value for this node. If there is no raw value for the parent, and no value is supplied, the default is false. Use this field if you have entities defined for some text, and you don’t want REXML to escape that text in output. "<&", false, nil, false ) #-> "<&" "<&", false, nil, false ) #-> "&lt;&amp;" "<&", false, nil, true )  #-> Parse exception "<&", false, nil, true )  #-> "<&"
# Assume that the entity "s" is defined to be "sean"
# and that the entity    "r" is defined to be "russell" "sean russell" )          #-> "&s; &r;" "sean russell", false, nil, true ) #-> "sean russell"

entity_filter (nil) This can be an array of entities to match in the supplied text. This argument is only useful if raw is set to false. "sean russell", false, nil, false, ["s"] ) #-> "&s; russell" "sean russell", false, nil, true, ["s"] ) #-> "sean russell"

In the last example, the entity_filter argument is ignored.


Show source
Register or log in to add new notes.