Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HowTo question - Combine two XML files

Status
Not open for further replies.

shlomyb

Programmer
Joined
Nov 14, 2006
Messages
32
Location
IL
I have two files.
One new file contains the other (old one )and has some additions.
I goal is two combine two files to one file that:
1.Preserves the old file structure.
2.Adds the new additions from the new one.

Please advice
 
How complex is your XML? There are a number of perl XML parsers with different capabilities, some of which are easier to use than others. XML::Simple is a basic one.

Essentially, you need to read the 'old' file into a data structure, and read the 'additions' file into another structure. Then iterate through the additions, find where they belong, and add them to the original structure. Then write it out.


Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::PerlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top