Created
November 3, 2010 19:58
-
-
Save tonycoco/661615 to your computer and use it in GitHub Desktop.
A quick script to convert JMeter log XML files to CSV files for Excel imports (Since, Excel can't import XML data... wow.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'nokogiri' | |
XML_FILE = ARGV[0] | |
CSV_FILE = ARGV[1] | |
if XML_FILE.nil? || CSV_FILE.nil? | |
puts 'usage: ruby jmeterxmltocsv.rb source_file target_file' | |
else | |
target_file = File.new(CSV_FILE, "w+") | |
xml_data = Nokogiri::XML(File.open(XML_FILE)) | |
xml_data.xpath('//httpSample').each do |item| | |
arr = [] | |
url = item.xpath('java.net.URL').first.content | |
arr << "\"#{url}\"" | |
item.each do |k, v| | |
arr << v | |
end | |
target_file.puts(arr.join(',')) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the script. Works like a charm.
For debian user, you must install nokogiri :