this is my first question (I hope not too stupid…) in this forum. I have looked for a solution here and in the web, but did not find anything.
When I create an object from an XML file like
$Main = [xml] (Get-Content -Path ($Source + $XMLMainDocument))
I can access the XML File like this
$BZRFromXML = $Main.archive.content.document.extension.property.value
And here is my problem:
If there is no such node in the object, I do not get a valid value. No Problem. If there are several ‘value’-nodes, I can access them as an array. No problem either. But if there is exactly one ‘value’, my code using the array notation does not work, because it is a single object, not an array. Thus, using  results in an error.
I have circumvented the problem by writing two code branches for no/several and one value. That is a lot of work and bad for maintenance. I am sure, there is a better way, I just don’t know it.
Can you help me?
Thanks for your time