Ruby on rails 如何在ruby(ROR)中获取相关的XML?

Ruby on rails 如何在ruby(ROR)中获取相关的XML?,ruby-on-rails,ruby,xml,Ruby On Rails,Ruby,Xml,我有以下XML: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <GetCustomerCentreDetailsResponse xmlns="http://tempuri.org/"> <GetCustomerCentreDetailsResult xmlns:i="http://www.w3.org/2001/XMLSchema-insta

我有以下XML:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetCustomerCentreDetailsResponse xmlns="http://tempuri.org/">
    <GetCustomerCentreDetailsResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:a="http://schemas.datacontract.org/2004/07/*****">
        <a:CustomerCentre>
            <a:CustomerCentreName>2 aaaaa Way </a:CustomerCentreName>     
            <a:CustomerCentreNumber>2</a:CustomerCentreNumber>
        </a:CustomerCentre>
        <a:CustomerCentre>
            <a:CustomerCentreName>Test Centre </a:CustomerCentreName>
            <a:CustomerCentreNumber>1</a:CustomerCentreNumber>
        </a:CustomerCentre>
    </GetCustomerCentreDetailsResult>
</GetCustomerCentreDetailsResponse>
</s:Body>
</s:Envelope>

2 aaaaa路
2.
考试中心
1.
我只想要两个客户中心。并展示它们。(并将它们添加到散列或其他内容中,以便我可以访问它们的数据。)

我的尝试没有成功,因为我不能忽略xml的其余部分,而且我不确定我做得是否正确

我们将感谢你的帮助


感谢Nokogiri是您的朋友,因为它能很好地解析XML:

例如:

   #auth_info = Nokogiri::HTML(open("http://tempuri.org"))
   #info = auth_info.xpath('//CustomerCentreName').text

我使用的代码如下:(谢谢你把我指给Nokogiri)


我试试看,谢谢。一直在使用一些不同的,但没有成功。当我确定需要哪一个时,它返回null。
reader = Nokogiri::XML::Reader(@response.to_xml)


reader.each do |node|
  # node is an instance of Nokogiri::XML::Reader
  if node.name == "#text"
    puts node.value
  end
end