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

  • Home
  • SEARCH
  • 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 9053801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:31:06+00:00 2026-06-16T13:31:06+00:00

I have an existing Nokogiri builder and some xml nodes in a string from

  • 0

I have an existing Nokogiri builder and some xml nodes in a string from a different source. How can I add this string to my builder?

str = "<options><cc>true</cc></options>"
xml = Nokogiri::XML::Builder.new do |q|
  q.query do |f|
    f.name "awesome"
    f.filter str
  end
end

This escapes str into something like:

xml.to_xml
=> "<?xml version=\"1.0\"?>\n<query>\n  <name>awesome</name>\n  <filter>&lt;options&gt;&lt;cc&gt;true&lt;/cc&gt;&lt;/options&gt;</filter>\n</query>\n"

I have found many, many similar things, including nesting builders and using the << operator, but nothing works to insert a full xml node tree into a builder block.
How can I make that string into real nodes?

  • 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-16T13:31:07+00:00Added an answer on June 16, 2026 at 1:31 pm

    What problems did you find using <<? This works for me:

    xml = Nokogiri::XML::Builder.new do |q|
      q.query do |f|
        f.name "awesome"
        f << str
      end
    end
    

    and avoids using the private insert method.

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

Sidebar

Related Questions

I've read about how you can generate changelog.xml from an existing schema. That's fine,
I have existing C++ lib containing many different classes working together. Some example usage
We have existing VS 2008 VSTO add-ins for Word 2003 and Excel 2003. We
I have an existing app in which I made the mistake of using String.GetHashCode
I am using Nokogiri to modify an existing XML but I am having trouble
i have existing code that generates a spreadsheet from excel using OpenXML. It works
I have this schema and i'm using JAXB to generate java stub files. <?xml
I have existing entity in datastore. I can find it Admin Console by attribute
I have existing reports that were fine in Report Builder 3, but now when
I have existing project and I want to add it in git local repository.

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.