Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails rails 3、xml格式和生成器_Ruby On Rails_Xml_Ruby On Rails 3_Builder - Fatal编程技术网

Ruby on rails rails 3、xml格式和生成器

Ruby on rails rails 3、xml格式和生成器,ruby-on-rails,xml,ruby-on-rails-3,builder,Ruby On Rails,Xml,Ruby On Rails 3,Builder,我有一个xml标记,它的格式如下: <AddDealRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 但很明显,第二个冒号正在摆脱符号。有没有办法摆脱第二个符号?或者这一声明是完全必要的 谢谢 尝试引用您的符号: xml.AddDealRequest( :'xmlns:xsi' => "http://w

我有一个xml标记,它的格式如下:

<AddDealRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
但很明显,第二个冒号正在摆脱符号。有没有办法摆脱第二个符号?或者这一声明是完全必要的


谢谢

尝试引用您的符号:

xml.AddDealRequest(
    :'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
    :'xmlns:xsd' => "http://www.w3.org/2001/XMLSchema"
)
您也可以尝试使用字符串而不是符号

xml.AddDealRequest(
    'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
    'xmlns:xsd' => "http://www.w3.org/2001/XMLSchema"
)
但我不知道建筑商是否会对此感到满意,但:

我不希望任何人在最早的答案中通读所有的评论,而是将结果发布在这里:


Firefox不显示
xmlns
属性(至少在匹配默认值时不显示)。如果查看源代码(Ctrl+U)或使用Chrome作为浏览器,您将看到缺少的属性出现在xml输出中。

不奇怪,这些情况都不起作用,即使只使用带有冒号的字符串。我一移除结肠,它就可以正常工作了……有没有办法逃出结肠?@Ryan:“不工作”在这种情况下是什么意思?例外?输出不正确?没有输出?啊,对不起!我应该澄清一下!输出在那里,没有例外,只是不正确。它的内容是:“xmlns:xsi=”“>@Ryan:如果你把一个
nocolon=>“东西”
扔到混合物里会怎么样?它会给你
?您正在使用哪个版本的builder?字符串和引号符号形式都适用于我。是的,如果没有冒号,它可以完美地工作。我有一个rails 3应用程序,但我使用的是builder 2.1.2Indeed,谢谢!我只是想知道为什么它没有在Firefox中显示xmlns:xxx属性!
xml.AddDealRequest(
    'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
    'xmlns:xsd' => "http://www.w3.org/2001/XMLSchema"
)
xm.target("name"=>"compile", "option"=>"fast")
# => <target option="fast" name="compile"\>
>> 'where_is:pancakes_house'.to_sym
=> :"where_is:pancakes_house"

>> :'xmlns:xsi'.to_s
=> "xmlns:xsi"