I'm trying to iterate through each node in an XML document. I can't seem to figure out how to do this. I'm doing this in PowerShell, but could translate from C#.
foreach ($file in Get-ChildItem ($directoryUrl+"\*.*") -include *.xml)
{
[xml]$xmlFile = Get-Content $file; #get content from xml file
Write-Host "Fff";
$firstNode = $xmlFile.DocumentElement;
$children = $firstNode.ChildNodes;
Now this gets the children of the first, node which is fine, but it's picking up Random
as a child, but I also want it to pick up what's inside the Random
XML tag. Like in the details tags.
How can I get this easily in PowerShell?
The XML I'm reading is:
<UserBase>
<User>
<Name>Kalle</Name>
</User>
<User>
<Name>Becker</Name>
</User>
<User>
<Name>Daniel</Name>
</User>
<User>
<Name>Anderson</Name>
</User>
<Random>
<Details>myself</Details>
<Details>mysdelf</Details>
</Random>
</UserBase>