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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:36:28+00:00 2026-05-28T18:36:28+00:00

I’m using ROXML to read and automatically build Ruby objects form properly formatted XML.

  • 0

I’m using ROXML to read and automatically build Ruby objects form properly formatted XML.

I’ve got nested resources, so within my XML I have, for example:

<blog ... >
  <post ... />
  <post ... />
  <post ... />
</blog>

Here’s the problem:

  1. When I read this url, I get back a blog object, upon which I can call blog.posts.count and I get back 3, as expected – that’s working.
  2. When I call blog.first I get back the first post in the posts collection, as defined by ROXML – that’s working.
  3. However, what isn’t working is calling the parent object. I’d like to be able to take a given post object and call post.blog to get its parent blog object back. How can I define this relationship on the post object? Do I simply define a method, and provide an xml_accessor declaration? This doesn’t seem right (and hasn’t worked), because xml_accessor methods are meant to pull attributes directly from XML, and within the post section of the XML, there will be no blog XML – it’s the other way around.

So, how do I access parent objects from a child object, from objects constructed via ROXML?

  • 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-05-28T18:36:30+00:00Added an answer on May 28, 2026 at 6:36 pm

    I’m more or less the current author/maintainer of ROXML (http://github.com/Empact).

    First I wonder, did you submit this: https://github.com/Empact/roxml/issues/36 That would be the current issue tracking this problem.

    In any case, the answer is the the library doesn’t current build up this relationship, and if you think of it, it’s not that crazy that we don’t, after all ActiveRecord doesn’t build both sides of a db relationship without symmetric has_many/belongs_to declarations.

    But ROXML can! After all the sub-objects are parsed as children under the higher-level object, we could just propagate down the parents info to establish the connection.

    I don’t have time at the moment to do this work, but if you’d like to make the addition to the library, I’m more than happy to vet and include it in the library.

    You might also look at Representable: https://github.com/apotonick/representable it was created in part from the ROXML codebase and is more actively maintained. Not sure if it has this feature.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I am reading a book about Javascript and jQuery and using one of 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.