[xml]$doc = Get-Content -LiteralPath 'C:\Users\tonycao\work\twincat3-auto-cli\TwinCAT_EL6695_Secondary\Logs\online_master.xml' -Encoding UTF8 Write-Host "=== EtherCAT Master XML keys ===" -ForegroundColor Cyan # Dump all distinct element names (first level under TreeItem) $doc.TreeItem | Get-Member -MemberType Property | ForEach-Object { Write-Host $_.Name } # Look for online-related fields $xmlText = $doc.OuterXml $patterns = @('Link', 'Frame', 'Online', 'State', 'Status', 'OpState', 'AlState', 'Tx', 'Rx', 'Slave', 'DeviceState', 'Connected') foreach ($p in $patterns) { $matches = [regex]::Matches($xmlText, "<$p[^>]*>[^<]*") if ($matches.Count -gt 0) { Write-Host "`nPattern $p found $($matches.Count) times:" -ForegroundColor Yellow foreach ($m in $matches | Select-Object -First 20) { Write-Host " $($m.Value)" } } } # Look for any attribute containing State/Link/Frame Write-Host "`n=== Attributes containing State/Link/Frame/Online ===" -ForegroundColor Cyan $nodes = $doc.SelectNodes('//*') foreach ($n in $nodes) { foreach ($a in $n.Attributes) { if ($a.Name -match 'State|Link|Frame|Online|Status|Op') { Write-Host " $($n.Name)@$($a.Name)=$($a.Value)" } } } # Write clean XML to file for manual inspection $doc.Save('C:\Users\tonycao\work\twincat3-auto-cli\TwinCAT_EL6695_Secondary\Logs\online_master_formatted.xml') Write-Host "`nFormatted XML saved to online_master_formatted.xml" -ForegroundColor Green