Note that there are some explanatory texts on larger screens.

plurals
  1. POGet Nokogiri to not add "default" namespace when adding nodes
    primarykey
    data
    text
    <p>Background:</p> <p>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.</p> <pre><code> &lt;default:ComponentRef Id="C__AD1817F9C64A42F0A14DDDDC82DFC8D9"/&gt; &lt;default:ComponentRef Id="C__157DD41D70854617A3D6D1E4A39B589F"/&gt; &lt;default:ComponentRef Id="C__2E6D8662F38FE62CAFA9F8842A28F510"/&gt; &lt;default:ComponentRef Id="C__54E5E2181323D4A5F37293DAA87B4230"/&gt; </code></pre> <p>Which I want to be just:</p> <pre><code> &lt;ComponentRef Id="C__AD1817F9C64A42F0A14DDDDC82DFC8D9"/&gt; &lt;ComponentRef Id="C__157DD41D70854617A3D6D1E4A39B589F"/&gt; &lt;ComponentRef Id="C__2E6D8662F38FE62CAFA9F8842A28F510"/&gt; &lt;ComponentRef Id="C__54E5E2181323D4A5F37293DAA87B4230"/&gt; </code></pre> <p>The following is my ruby code:</p> <pre><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 } </code></pre> <h2>Update</h2> <p>Example of my template file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'&gt; &lt;Fragment&gt; &lt;ComponentGroup Id='MSIComponentGroup'&gt; &lt;/ComponentGroup&gt; &lt;/Fragment&gt; &lt;Fragment Id='MSIComponents'&gt; &lt;DirectoryRef Id='InstallDir'&gt; &lt;/DirectoryRef&gt; &lt;/Fragment&gt; &lt;/Wix&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload