通过第三方 Web 服务收集 xml 响应
我已使用此命令将 xml 文件发送到名为 SRA-ENA 的 Web 服务。
submission_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.submission.xml"), 'SUBMISSION')
study_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.study.xml"), 'STUDY')
sample_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.sample.xml"), 'SAMPLE')
run_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.run.xml"), 'RUN')
experiment_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.experiment.xml"), 'EXPERIMENT')
# Send these requests to the test-SRA website
request_test = Curl::Easy.http_post("https://www-test.ebi.ac.uk/ena/submit/drop-box/submit/?auth=ERA%20era-drop-81%20dxjf2dntWDr4CHg28qERORnv0RQ%3D", submission_field, study_field, sample_field, run_field, experiment_field )
作为回应,我收到了来自网络服务器的 xml 格式的收据,
请有人指导我如何将此 xml 保存在变量中,以便我可以使用 nokogiri 进一步解析 xml 文件。
I have used this command to send xml files to a web service named SRA-ENA.
submission_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.submission.xml"), 'SUBMISSION')
study_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.study.xml"), 'STUDY')
sample_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.sample.xml"), 'SAMPLE')
run_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.run.xml"), 'RUN')
experiment_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.experiment.xml"), 'EXPERIMENT')
# Send these requests to the test-SRA website
request_test = Curl::Easy.http_post("https://www-test.ebi.ac.uk/ena/submit/drop-box/submit/?auth=ERA%20era-drop-81%20dxjf2dntWDr4CHg28qERORnv0RQ%3D", submission_field, study_field, sample_field, run_field, experiment_field )
In response to this, I receive a receipt from the web server in xml format,
Please could some one guide me how to save this xml in a variable so that I can use nokogiri to further parse the xml file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个使用 Rails 2.3.14 的独立示例,展示了如何使用 nokogiri 解析 XML 结果。
Here is a standalone example, using Rails 2.3.14, that shows how to use nokogiri to parse XML results.