require "AP233_ARM_LF" require 'rexml/document' include REXML include AP233 ## ## Identify the input file and create an in-memory REXML XML document infile = File.new("data.xml","r") doc = REXML::Document.new infile ## Create an AP233 model container for the instances m = AP233::Model___data.new ## ## Use the ap233 XML Namespace (it's what's in the XML input file) m.namespace = "ap233" ## ## Clear out the model_elements list. m.model_elements = [] ## ## Read the in-memory XML doc into the AP233 Model__data container. ## This one method reads the entire XML file. m.readP28e2(doc) ## ## Print the XML ID of what's been read into the AP233 Model__data container if m.model_elements.size != 0 puts "Copied " + m.model_elements.size.to_s for e in m.model_elements puts "p28id = " + e.getP28id.to_s end ## ## Set up the XML file and write all data in the model container to a new file datafile = File.new("data_copy.xml","w") p28file = REXML::Document.new m.writeP28e2 p28file datafile.puts p28file datafile.close end