Savon과 비누 호출을했습니다. 이 잘 작동하고 다음과 같은 응답이 제공 :Savon과 SOAP 호출에서 Nokogiri의 응답 읽기
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://
schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetTop10Response xmlns="http://www.kirupafx.com">
<GetTop10Result>
<string>string</string>
<string>string</string>
</GetTop10Result>
</GetTop10Response>
</soap:Body>
</soap:Envelope>
지금 내가 응답에서 문자열의 모든 요소를 먹고 싶어합니다. 그러나 나는 그것을 작동시킬 수 없다.
def query(params=nil)
client = Savon::Client.new do
wsdl.document = "http://www.kirupafx.com/WebService/TopMovies.asmx?wsdl"
end
response = client.request :get_top10
if response.success?
xml = Nokogiri::XML(response.to_xml)
print "Until here oké!"
xml.search('//GetTop10Result').each do |result|
print "How are you Ruby?"
@result[result.at('string').inner_text] = result.at('string').inner_text
end
else
raise "Error!"
end
그러나 그는 내 "아름다운 루비"를 인쇄하지 않습니다. 누군가가 나를 도와 드릴까요 나요? 내가 뭘 잘못하고있어?
'xml.search'를'xml.xpath'로 바꾸면 어떻게됩니까? – ScottJShea