Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8983607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:52:55+00:00 2026-06-15T20:52:55+00:00

I’ve been assigned a task to do with Ruby, but as I’m new to

  • 0

I’ve been assigned a task to do with Ruby, but as I’m new to it I’m searching over the internet for a proper solution to solve it:

  1. I have a list of log files reports in a web page actually divided in passed or failed.
  2. I need to take log files and convert them into a format compatible with Jenkins Junit XML File format.
  3. Everything, the passage from log to XML has to be written in Ruby.

Any ideas?!

I looked all over the internet and found information but still have no clear ideas how to solve this.

Are there any Ruby libraries that make this easier?
Has anyone ever handled anything like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:52:57+00:00Added an answer on June 15, 2026 at 8:52 pm

    You don’t show the format you need, and I don’t know what Jenkins needs, but creating XML is easy. Unfortunately, what you want will take a book, or several articles, which is beyond the scope of Stack Overflow. Basically though…

    You can use a templating system, like ERB where you create templates for your overall XML document, or Nokogiri::Builder can be used to generate XML, or you can do it old school and use simple string interpolation to create your XML.

    A syslog file is typically fairly well structured, at least for the first several fields, followed by free-form text which is the output of various commands. A log file from Apache is similar, with columns of text, followed by some free-form, but easily parsable text. There are gems here and there, along with tutorials on how to parse a log, so search around and you’ll find something. The idea is you want to break down each line read into text you can assign to an XML node.

    Once you have your fields, you can substitute them into the template or have Ruby interpolate the variables into strings, or use Builder to add the text between the tags.

    It’s not really hard, but is going to take several small tasks to accomplish.

    Using string interpolation, if you wanted XML like:

    <xml>
      <tag1>
        <tag2>some text</tag2>
        <tag2>some more text</tag2>
      </tag1>
    </xml>
    

    You could create it like:

    var1 = "some text"
    var2 = "some more text"
    xml = %Q{
    <xml>
      <tag1>
        <tag2>#{var1}</tag2>
        <tag2>#{var2}</tag2>
      </tag1>
    </xml>
    }
    puts xml
    

    Similarly, if you want to use ERB:

    require 'erb'
    
    var1 = "some text"
    var2 = "some more text"
    
    template = ERB.new <<-EOF
    <xml>
      <tag1>
        <tag2><%= var1 %></tag2>
        <tag2><%= var2 %></tag2>
      </tag1>
    </xml>
    EOF
    puts template.result(binding)
    

    Which outputs:

    <xml>
      <tag1>
        <tag2>some text</tag2>
        <tag2>some more text</tag2>
      </tag1>
    </xml>
    

    Or, using Nokogiri::Builder:

    require 'nokogiri'
    
    var1 = "some text"
    var2 = "some more text"
    builder = Nokogiri::XML::Builder.new do |node|
      node.xml {
        node.tag1 {
          [var1, var2].each do |t|
            node.tag2(t)
          end
        }
      }
    end
    puts builder.to_xml
    

    Which outputs:

    <?xml version="1.0"?>
    <xml>
      <tag1>
        <tag2>some text</tag2>
        <tag2>some more text</tag2>
      </tag1>
    </xml>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have been unable to fix a problem with Java Unicode and encoding. The
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.