Is there a way to do something like:
x = Builder::XmlMarkup.new(:target => $stdout, :indent => 1) x.instruct! x.response{ x.XXXXX{
XXXXX is a variable sent in to a method.
Is there a way to do something like:
x = Builder::XmlMarkup.new(:target => $stdout, :indent => 1) x.instruct! x.response{ x.XXXXX{
XXXXX is a variable sent in to a method.
Chris Habgood wrote:
Is there a way to do something like:
x = Builder::XmlMarkup.new(:target => $stdout, :indent => 1) x.instruct! x.response{ x.XXXXX{
XXXXX is a variable sent in to a method.
Can you clarify? I don't understand your question.
x.XXXXX { ... } would create an XML tag named "XXXXX"
<?xml version="1.0"?> <response> <XXXXX> ... </XXXXX> </response>
Attributes are added by passing in a hash x.XXXXX(:title => "foo", name => "bar") { ... }
<?xml version="1.0"?> <response> <XXXXX title="foo" name="bar"> ... </XXXXX> </response>
What are you actually trying to do?
Take success or error in as a text and replace the below with:
if type.eql?(‘success’) x.success do x.message “#{msg}” end else x.error do
x.message "#{msg}"
end
end
Final version: remove the duplication. type = “success” or “error” x.type do x.message “”