我得到 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"
所以我需要删除“标志。有人可以帮我吗?