From: Lars Haugseth Date: 2012-04-26T19:49:29+09:00 Subject: Re: if if if statment On 04/26/2012 11:23 AM, fox foxmaster wrote: > Lars I thought I check out nokogiri ^^ and humm I feel completely lost, > I am trying to find examples on how to use it in the way that I want, I > really don't get the examples on the nokogiri web page, > > So Lars or anyone else, would you like to show me howto use it in the > code I have? > First, you need to parse the source XML into a DOM object: require 'nokogiri' dom = Nokogiri::XML(File.read source_file) Then you iterate over all InterfaceGroup nodes and modify attributes: dom.xpath("//InterfaceGroup").each do |node| node['Members'] = "some value" end Finally, write the modified DOM to the target XML file: File.open(target_file, "w") { |f| f.write dom.to_xml } -- Lars Haugseth