OK, I have an xml file with following contents:
<?xml version="1.0" ?>
<Objects>
<Object Name="Name01">
<Number>123465</Number>
<Pictures FolderName="D:\Temp\Pictures01">
<Picture Name="0001.jpg"/>
<Picture Name="0002.jpg"/>
<Picture Name="0003.jpg"/>
<Picture Name="0004.jpg"/>
</Pictures>
</Object>
<Object Name="Name02">
<Number>123465</Number>
<Pictures FolderName="D:\Temp\Pictures01">
<Picture Name="0005.jpg"/>
<Picture Name="0006.jpg"/>
</Pictures>
</Object>
<Object Name="Name03">
<Number>123465</Number>
<Pictures FolderName="D:\Temp\Pictures01">
<Picture Name="0013.jpg"/>
</Pictures>
</Object>
<Object Name="Name04">
<Number>123465</Number>
</Object>
</Objects>
I read it in using this statement:
$MyXMLFile = [xml] (Get-Content -Path ".\MyXMLFile.xml")
I get the first "Object"
$CurrentObject = $MyXMLFile.Objects.Object | Select-Object -First 1
Then I see how many "Pictures" it points to:
$CurrentObject.Pictures.Picture.Count
This gives me 4
I get the next object
$CurrentObject = $MyXMLFile.Objects.Object | Select-Object -First 1 -Skip 1
$CurrentObject.Pictures.Picture.Count
This gives me 2
Now the surprise:
$CurrentObject = $MyXMLFile.Objects.Object | Select-Object -First 1 -Skip 2
$CurrentObject.Pictures.Picture.Count
This gives me $Null, apparently it doesn't even have a Count member even though its a System.Xml.XmlElement like the previous two.
The next step is logical again
$CurrentObject = $MyXMLFile.Objects.Object | Select-Object -First 1 -Skip 3
$CurrentObject.Pictures.Picture.Count
This gives me 0
Can anyone explain the $Null?