Given a single XML node like this
<MachineLogFileName overwrite="[bool]"></MachineLogFileName>
and assigned to a variable like this
$validationNode = $validation.xml.SelectSingleNode("//Settings/$($node.name)")
where of course $node.name is 'MachineLogFileName', and a variable $attribute.name of 'overwrite', I want to be able to get the value of that attribute, but only as an attribute. I can use $validationNode.($attribute.name), but IF there was a child node called <overwrite>
and wasn't an attribute called 'overwrite' I would end up getting the inner text of the child node. So in a sense I want something like $validationNode.Attributes.($attribute.name). It seems like there is a collection there, with a single attribute in this case, but I can't seem to get the value this way. Ultimately this needs to work with highly variable attribute and child node names, and I could just loop through all the attributes, but I need this in an IF so something like $validationNode.Attributes.($attribute.name) would be ideal. And seems like it should be possible and I am just missing one aspect? I hope.