0
압축을 풀고 구문 분석해야하는 외부 xml 파일 다운로드가 있습니다. 나는 그것을 다운로드하고 압축을 풀었지만 지금은 Zip :: Entry 객체로 붙어 있으며 Nokogiri와 구문 분석 할 수 없다.XML 파일을 압축 해제 한 후 Zip :: Entry 개체 읽기
require 'open-uri'
require 'zip'
require 'nokogiri'
url = 'https://download.api.bingads.microsoft.com/ReportDownload/Download.aspx?xmlfile'
zip_file = open(url)
# file pulled down successfully => tmp/localpath
unzippedxml = Zip::File.open(zip_file.path) do |z|
xml_file = z.first
end
#output is my xml file => myxml.xml
unzippedxml.class => Zip::Entry
Nokogiri::XML("unzippedxml")
=> #<Nokogiri::XML::Document:0x212b2c0 name="document")
이 파일을 어떻게 분석합니까? 나는 압축을 풀 필요가없는 더미 XML 파일을 만들었고 콘솔에서 파싱 할 수 있었지만이 파일을 열 수는 없습니다.
도움이 될 것입니다.