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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:21:27+00:00 2026-05-12T12:21:27+00:00

I am a adding a couple of simple elements to a bunch of XML

  • 0

I am a adding a couple of simple elements to a bunch of XML files (plists). The existing XML element I am working on looks like this:

<dict>
  <key>background</key>
  <string>#FFFFFF</string>
  <key>caret</key>
  <string>#000000</string>
  <key>foreground</key>
  <string>#000000</string>
  <key>invisibles</key>
  <string>#BFBFBF</string>
  <key>lineHighlight</key>
  <string>#00000012</string>
  <key>selection</key>
  <string>#BAD6FD</string>
</dict>

I have captured this element in an object called settings and I am adding new <key> and <string> elements, and adding some text to those elements. Simple enough so far:

settings.add_element('key').add_text('gutter')
settings.add_element('string').add_text('#282828')

Trouble is, when I write this back out, the XML looks like this (note the last line):

<dict>
  <key>background</key>
  <string>#FFFFFF</string>
  <key>caret</key>
  <string>#000000</string>
  <key>foreground</key>
  <string>#000000</string>
  <key>invisibles</key>
  <string>#BFBFBF</string>
  <key>lineHighlight</key>
  <string>#00000012</string>
  <key>selection</key>
  <string>#BAD6FD</string>
<key>gutter</key><string>#282828</string></dict>

I am using the write (REXML::Document) method to write out the XML (to $stdout at the moment):

tmtheme.write( $stdout )

Also tried

tmtheme.write( $stdout, 2 )

But these don’t return the desired results. The following looked promising:

tmtheme.write( $stdout, 2, true )

But this gives me a known error. Update: just tried it on Ruby 1.9 and although I don’t get the erro, it doesn’t help – I still get the formatting as seen in the example above.

Can anyone tell me how I can format the XML so that it conforms to the formatting style of the rest of the document? It doesn’t necessarily need to be done with REXML.

  • 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-12T12:21:28+00:00Added an answer on May 12, 2026 at 12:21 pm

    Robert Klemme and Aaron Patterson came up with the goods on the ruby-talk list.

    This is the first time a question I’ve posed on SoF has drawn a complete blank.

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

Sidebar

Related Questions

Adding an element to the head of an alist (Associative list) is simple enough:
This simple code is not producing any sound on a couple of machines that
Adding source files more than one directory away (e.g. ../../source.cpp or ../../../somewhere_else/source.cpp, vs. just
I'm looking at adding scripting functionality to an existing codebase and am weighing up
The current application uses Simple Java Mail to send couple emails a day but
I have a couple of databases containing simple data which needs to be imported
Here a couple of examples in a pseudocode to show what I mean. This
I've only been able to find a couple of people online mentioning this, and
I recently developed a simple application for displaying a list of files to some
When adding new properties to classes, I find myself typing the same things over

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.