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 9268993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:59:50+00:00 2026-06-18T14:59:50+00:00

I need to generate XML using ox but didn’t get much help from the

  • 0

I need to generate XML using ox but didn’t get much help from the documentation. I need to generate XML like this:

<Jobpostings>
  <Postings>
    <Posting>
      <JobTitle><cdata>Programmer Analyst 3-IT</cdata></JobTitle>
      <Location><cdata>Romania,Bucharest...</cdata></Location>
      <CountryCode><cdata>US</cdata>   </CountryCode>
      <JobDescription><cdata>class technology to develop.</cdata></JobDescription>             
    </Posting>     
  </Postings>
</jobpostings>

I have the data inside the tags as strings in variables like this:

jobtitle = "Programmer Analyst 3-IT" and so on...

I am currently using Nokogiri to generate XML but I need to work on large data, and, for the performance sake I am moving to Ox.

Any ideas on how to do 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-18T14:59:52+00:00Added an answer on June 18, 2026 at 2:59 pm

    It’s pretty simple, you just initialize new elements and append them to other elements. Unfortunately there isn’t an XML builder in the Ox library though… Here’s an example:

    require 'ox'
    include Ox
    
    source = Document.new
    
    jobpostings = Element.new('Jobpostings')
    source << jobpostings
    
    postings = Element.new('Postings')
    jobpostings << postings
    
    posting = Element.new('Posting')
    postings << posting
    
    jobtitle = Element.new('JobTitle')
    posting << jobtitle
    jobtitle << CData.new('Programmer Analyst 3-IT')
    
    location = Element.new('Location')
    posting << location
    location << CData.new('Romania,Bucharest...')
    
    countrycode = Element.new('CountryCode')
    posting << countrycode
    countrycode << CData.new('US')
    countrycode << '   '
    
    jobdescription = Element.new('JobDescription')
    posting << jobdescription
    jobdescription << CData.new('class technology to develop.')
    
    puts dump(source)
    

    Returns:

    <Jobpostings>
      <Postings>
        <Posting>
          <JobTitle>
            <![CDATA[Programmer Analyst 3-IT]]>
          </JobTitle>
          <Location>
            <![CDATA[Romania,Bucharest...]]>
          </Location>
          <CountryCode>
            <![CDATA[US]]>   </CountryCode>
          <JobDescription>
            <![CDATA[class technology to develop.]]>
          </JobDescription>
        </Posting>
      </Postings>
    </Jobpostings>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to generate some XML using XML::Builder, but my element names need to
I need to generate the XML from the SQL Server 2008 R2 using 'For
I need to generate an xml from windows command prompt using the forfiles command.
I'm using ActiveSupport's to_xml to generate some xml from a hash. I have need
What tool do I need to generate XML intellisense help file as shown below?
I am creating XML using a while loop, but now I need to prepend
I need to generate XML structures on the fly using PHP. I've seen many
I'm using SimpleXML to generate xml based invoice. The structure has to be like
I need to generate a number of XML documents from Java objects. The objects
I'm using XmlTextWriter to generate XML from a C# app. The initial input will

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.