Well, i need to move xml node position inside same xml file
I've got this xml:
<METATRANSCRIPT:METATRANSCRIPT xmlns:METATRANSCRIPT="http://www.mpi.nl/IMDI/Schema/IMDI" xmlns="http://www.mpi.nl/IMDI/Schema/IMDI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ArchiveHandle="hdl:2196/00-0000-0000-0013-2CB3-2" Date="2012-02-08" FormatId="IMDI 3.0" Originator="Editor - Profile:local/SESSION.Profile.xml" Type="SESSION" Version="3" xsi:schemaLocation="http://www.mpi.nl/IMDI/Schema/IMDI ./IMDI_3.0.xsd">
<Session>
<Name>Acknowledgement</Name>
<Title>Acknowledgement written by Maria Alzira Roque Gameira in her Master's Thesis</Title>
<Date>2009-09-16</Date>
<Description LanguageId="ISO639-3:eng" Link="">Maria Alzira Roque Gameiro (MD009) reads aloud the acknowledgement she wrote in Minderico for her Master Thesis on museology. </Description>
<MDGroup>
<Actors>
<Name>Sabine Wurm</Name>
<FullName>Sabine Wurm</FullName>
</Actor>
</Actors>
</MDGroup>
</METATRANSCRIPT:METATRANSCRIPT>
<imdi xmlns="http://www.mpi.nl/IMDI/Schema/IMDI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" FormatId="IMDI 3.03" Originator="" Type="SESSION" Version="1" xsi:schemaLocation="http://www.mpi.nl/IMDI/Schema/IMDI">
<Session>
<MDGroup>
<Actors>
<Actor>
<Name/>
<FullName/>
</Actor>
<Actor>
<Name/>
<FullName/>
</Actor>
<Actor>
<Name/>
<FullName/>
</Actor>
<Actor>
<Name/>
<FullName/>
</Actor>
</Actors>
</MDGroup>
</Session>
</imdi>
The ideia is to move each Actor inside imdi, and insert it after the first Actor inside METATRANSCRIPT:METATRANSCRIPT. This way i will have all actors in the same parent (METATRANSCRIPT)
My code:
Get-ChildItem -Path 'C:\Scripts\Source\' -Recurse -Include "*.xml" -File| ForEach-Object{
[xml]$xml = Get-Content $_.FullName;
$xml.imdi.Session.MDGroup.Actors
...
...
$xml.Save($_.FullName)}
My issue is :
how can i select and move each node, before using insertafter() method ? Thanks a lot for any help on this. I don't know how to start.
Expected Output:
<METATRANSCRIPT:METATRANSCRIPT xmlns:METATRANSCRIPT="http://www.mpi.nl/IMDI/Schema/IMDI" xmlns="http://www.mpi.nl/IMDI/Schema/IMDI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ArchiveHandle="hdl:2196/00-0000-0000-0013-2CB3-2" Date="2012-02-08" FormatId="IMDI 3.0" Originator="Editor - Profile:local/SESSION.Profile.xml" Type="SESSION" Version="3" xsi:schemaLocation="http://www.mpi.nl/IMDI/Schema/IMDI ./IMDI_3.0.xsd">
<Session>
<Name>Acknowledgement</Name>
<Title>Acknowledgement written by Maria Alzira Roque Gameira in her Master's Thesis</Title>
<Date>2009-09-16</Date>
<Description LanguageId="ISO639-3:eng" Link="">Maria Alzira Roque Gameiro (MD009) reads aloud the acknowledgement she wrote in Minderico for her Master Thesis on museology. </Description>
<MDGroup>
<Actors>
<Actor>
<Name>Sabine Wurm</Name>
<FullName>Sabine Wurm</FullName>
</Actor>
<Actor>
<Name/>
<FullName/>
</Actor>
<Actor>
<Name/>
<FullName/>
</Actor>
<Actor>
<Name/>
<FullName/>
</Actor>
<Actor>
<Name/>
<FullName/>
</Actor>
</Actors>
</MDGroup>
</Session>
</METATRANSCRIPT:METATRANSCRIPT>