'ruby xml builder send text
I am trying to run though a program and send string literal value of variable to xml markup using xml.text! var_name. This var_name is having xml tag opening and closing, when i use the below code it covert < and > symbol into escape chars like < > respectively.
is it possible to achive my desired effect using builder
file = File.new("output.xml", "wb")
x = Builder::XmlMarkup.new(:target => file, :indent => 2)
x.instruct!
var_name += "<tag1>value"
var_name += "</tag1>"
xml.text! var_name
actual output is:
<tag1>value</tag1>
desired output:
<tag1>value</tag1>
Solution 1:[1]
Is xml a typo? It should be x.text!, right? Did you try to use x << var_name instead of x.text! var_name? This method appends text without escaping markup
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
