我获取了xml数据,并从中获得了价值。
我需要删除符号[和]
这是我的代码,它给出了有关未定义变量的错误:
@xml = XmlSimple.xml_in(res.content)//here I get xml document
payKey = @xml["payKey"]//gere I get needed value
//it looks like "[some character]" so I need to delete [ and ]
//I tried
payKey = @xml["payKey"].to_s()//to use tr method
payKey = payKey.tr("[]", "")//replacing
redirect_to "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay?cmd=_ap-payment&paykey=#{paykey}"//inserting into url
和结果:
svcs.sandbox.paypal.com/AdaptivePayments/Pay?cmd=_ap-payment&paykey="AP-7NK73769LH704515X"
所以我需要删除“迹象。有人可以帮助我吗?
答案 0 :(得分:0)
我的愚蠢回答
payKey = payKey[1..20]