function Remove-NodeAttributes {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$Node,
[Parameter(Mandatory=$true)]
[string[]]$AttributesToRemove
)
$selectedNodes = $xml.SelectNodes("//"+$Node)
foreach ($selectedNode in $selectedNodes) {
# Remove each specified attribute from the node
foreach ($attribute in $AttributesToRemove) {
$selectedNode.RemoveAttribute($attribute)
}
}
}
function DeleteNode {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$Node
)
# Delete node
# Select the nodes
$deleteNodes = $xml.SelectNodes("//"+$Node)
# Delete each node
foreach ($deleteNode in $deleteNodes) {
[void]$deleteNode.ParentNode.RemoveChild($deleteNode)
}
}
# ADE F20 uses open and close tags for TaxiwayPath elements. ADE P4 uses only a single empty tag. We need to update these to avoid errors
function UpdateToEmptyTags {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$Node
)
# Select all matching nodes
$selectedNodes = $xml.SelectNodes("//"+$Node)
foreach ($selectedNode in $selectedNodes) {
# Replace the node with an empty tag
$newNode = $xml.CreateElement($Node)
$selectedNode.Attributes | ForEach-Object {
[void]$newNode.SetAttribute($_.Name, $_.Value)
}
$selectedNode.ParentNode.ReplaceChild($newNode, $selectedNode)
}
}
# Get the path to the XML file
$xmlFilePath = Read-Host "Enter the path to the XML file"
# Load the XML file
$xml = New-Object -TypeName System.Xml.XmlDocument
$xml.Load($xmlFilePath)
DeleteNode -Node "DeleteNavigation"
Remove-NodeAttributes -Node "SceneryObject" -AttributesToRemove @("snapToGround", "snapToNormal")
Remove-NodeAttributes -Node "Airport" -AttributesToRemove @("altType","isOnTIN","onlyAddIfReplace","applyFlatten","starAirport","closed","groundMergingTransfertBright","groundMergingTransfertDark")
Remove-NodeAttributes -Node "DeleteAirport" -AttributesToRemove @("deleteAllLightSupports","deleteAllTerminalNDBs","deleteAllPaintedElements","deleteAllTaxiwaySigns","deleteAllTerminalWaypoints","deleteAllILSs","deleteAllDepartures","deleteAllArrivals")
Remove-NodeAttributes -Node "Runway" -AttributesToRemove @("altType","falloff","groundMerging","excludeVegetationAround")
DeleteNode -Node "RunwayDeformation"
Remove-NodeAttributes -Node "ApproachLights" -AttributesToRemove @("offset","slope","spacing")
Remove-NodeAttributes -Node "RunwayStart" -AttributesToRemove @("altType")
Remove-NodeAttributes -Node "TaxiwayParking" -AttributesToRemove @("has3DMesh","numberMarking","suffix")
Remove-NodeAttributes -Node "TaxiwayPath" -AttributesToRemove @("enhanced","groundMerging","excludeVegetationAround","excludeVegetationInside")
DeleteNode -Node "Jetway"
DeleteNode -Node "SceneryObject[SimObject]"
Remove-NodeAttributes -Node "Apron" -AttributesToRemove @("opacity","localUV","stretchUV","isRectangle","tiling","falloff","groundMerging","excludeVegetationAround","flipUV","offsetU","offsetV","excludeVegetationInside","priority")
Remove-NodeAttributes -Node "Vertex" -AttributesToRemove @("spline")
Remove-NodeAttributes -Node "TaxiwayPath" -AttributesToRemove @("centerLine","centerLineLighted","leftEdge","leftEdgeLighted","rightEdge","rightEdgeLighted")
#Update TaxiWayPath nodes from using open and close tags to singular empty tags
UpdateToEmptyTags -Node "TaxiwayPath"
# Save the modified XML to a new file
$outputFilePath = $xmlFilePath -replace '\.xml$', '_modified.xml'
$xml.Save($outputFilePath)
$xml = Get-Content -Path $outputFilePath
$xml = $xml -replace 'surface="{.*?}"','surface="ASPHALT"'
Set-Content $outputFilePath $xml
Write-Host "Modified XML saved to $outputFilePath"