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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:21:47+00:00 2026-05-19T01:21:47+00:00

Background: I want to take some xml from one file, put it in a

  • 0

Background:

I want to take some xml from one file, put it in a template file and then save the modified template as a new file. It works, but when I save the file out, all the nodes that I added have a default namespace prepeneded, i.e.

        <default:ComponentRef Id="C__AD1817F9C64A42F0A14DDDDC82DFC8D9"/>
        <default:ComponentRef Id="C__157DD41D70854617A3D6D1E4A39B589F"/>
        <default:ComponentRef Id="C__2E6D8662F38FE62CAFA9F8842A28F510"/>
        <default:ComponentRef Id="C__54E5E2181323D4A5F37293DAA87B4230"/>

Which I want to be just:

        <ComponentRef Id="C__AD1817F9C64A42F0A14DDDDC82DFC8D9"/>
        <ComponentRef Id="C__157DD41D70854617A3D6D1E4A39B589F"/>
        <ComponentRef Id="C__2E6D8662F38FE62CAFA9F8842A28F510"/>
        <ComponentRef Id="C__54E5E2181323D4A5F37293DAA87B4230"/>

The following is my ruby code:

file = "wixmain/generated/DarkOutput.wxs"
template = "wixmain/generated/MsiComponentTemplate.wxs"
output = "wixmain/generated/MSIComponents.wxs"

dark_output = Nokogiri::XML(File.open(file))
template_file = Nokogiri::XML(File.open(template))

#get stuff from dark output
components = dark_output.at_css("Directory[Id='TARGETDIR']")
component_ref = dark_output.at_css("Feature[Id='DefaultFeature']")

#where to insert in template doc
template_component_insert_point = template_file.at_css("DirectoryRef[Id='InstallDir']")
template_ref_insert_point = template_file.at_css("ComponentGroup[Id='MSIComponentGroup']")

template_component_insert_point.children= components.children()
template_ref_insert_point.children= component_ref.children()

#write out filled template to output file
File.open(output, 'w') { |f| template_file.write_xml_to f }

Update

Example of my template file:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
  <Fragment>
    <ComponentGroup Id='MSIComponentGroup'>
    </ComponentGroup>
  </Fragment>
  <Fragment Id='MSIComponents'>
      <DirectoryRef Id='InstallDir'>
      </DirectoryRef>
  </Fragment>
</Wix>
  • 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-19T01:21:47+00:00Added an answer on May 19, 2026 at 1:21 am

    Workaround was to remove the xmlns attribute in the input file.

    Or to use the remove_namespaces! method when opening the input file

    input_file = Nokogiri::XML(File.open(input))
    input_file.remove_namespaces!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.