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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:41:35+00:00 2026-06-17T13:41:35+00:00

I want to communicate between ruby and other applications in XML. I have defined

  • 0

I want to communicate between ruby and other applications in XML. I have defined a schema for this communication and I’m looking for the best way to do the transformation from data in Ruby to the XML and vice versa.

I have an XML document my_document.xml:

<myDocument>
  <number>1</number>
  <distance units="km">20</distance>
</myDocument>

Which conforms to an Schema my_document_type.xsd (I shalln’t bother writing it out here).

Now I’d like to have the following class automatically generated from the XSD – is this reasonable or feasible?

# Represents a document created in the form of my_document_type.xsd
class MyDocument
  attr_accessor :number, :distance, :distance_units

  # Allows me to create this object from data in Ruby
  def initialize(data)
    @number = data['number']
    @distance = data['distance']
    @distance_units = data['distance_units']
  end

  # Takes an XML document of the correct form my_document.xml and populates internal systems
  def self.from_xml(xml)
    # Reads the XML and populates:
    doc = ALibrary.load(xml)

    @number = doc.xpath('/number').text()
    @distance = doc.xpath('/distance').text()
    @distance_units = doc.xpath('/distance').attr('units') # Or whatever
  end

  def to_xml
    # Jiggery pokery
  end
end

So that now I can do:

require 'awesomelibrary'

awesome_class = AwesomeLibrary.load_from_xsd('my_document_type.xsd')

doc = awesome_class.from_xml('my_document.xml')

p doc.distance # => 20
p doc.distance_units # => 'km'

And I can also do

doc = awesome_class.new('number' => 10, 'distance_units' => 'inches', 'distance' => '5')

p doc.to_xml

And get:

<myDocument>
  <number>10</number>
  <distance units="inches">5</distance>
</myDocument>

This sounds like fairly intense functionality to me, so I’m not expecting a full answer, but any tips as to libraries which already do this (I’ve tried using RXSD, but I can’t figure out how to get it to do this) or any feasibility thoughts and so on.

Thanks in advance!

  • 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-17T13:41:37+00:00Added an answer on June 17, 2026 at 1:41 pm

    Have you tried Nokogiri? The Slop decorator implements method_missing into the document in such a way that it essentially duplicates the functionality you’re looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to communicate between Zend Modules as stated below? I want
I am looking to find a way to communicate between 2 VPCs in AWS
Hi I've done a lot of research on the best way to communicate between
I have an application in Lua, I want to communicate between the Lua application
I want to communicate between two or more dialog windows,when i say communicate It
I want to use netlink to communicate between an application and kernel space. My
What is the difference between TCP listener and TCP server? I want to communicate
I have 2 apps that I want to make communicate via named pipes on
I am creating server-client application for iPhone. I want to communicate between two application
For many years I have used the old SAP DCOM Connector to communicate between

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.