XML Merge
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: XML Merge
Ok dont know how else to explain it or show it to you. But thank you for your advice on the iteration. Think I have an idea of how I am going to do this. Will post this my results. Thank you for the help.
Re: XML Merge
Sorry but unless you can produce a real world example there is no way to know what to tell you to do. There is no way to generalize what you are asking. It can easily be done for those two files if we make a whole lot of limiting assumptions that would be true only for those exact files. Any changes would likely invalidate the assumptions.
With data we need to have a true representation of data that has true relationships and meaning. Random data is never easy to work with. We must have a known starting place as in all programming, science and technology.
With data we need to have a true representation of data that has true relationships and meaning. Random data is never easy to work with. We must have a known starting place as in all programming, science and technology.
Re: XML Merge
Have you tried this?
- $finalXml = "<root>"
- foreach ($file in $files) {
- [xml]$xml = Get-Content $file
- $finalXml += $xml.InnerXml
- }
- $finalXml += "</root>"
- ([xml]$finalXml).Save("$pwd\final.xml")
Re: XML Merge
This does NOT merge XML. It concatenates the contents of the files which is not what the word "merge" means.
The OP is asking for something that is vague and requires some kind of copying of specific elements and attributes between XML objects that are not well specified in the question. That is why I requested a real example and not a simplified and broken example that does not clarify the task well enough.
XML is highly structured data. It is not text and concatenating XML will not perform any kind of data merge operation.