Asserts that a node doesn't exist in an XML document.
Assert-NodeDoesNotExist [-Xml] <XmlDocument> [-XPath] <String> [[-DefaultNamespacePrefix] <String>] [[-Message] <String>] [<CommonParameters>]
It's usually pretty easy in PowerShell to check if a node doesn't exist in an XML document: simply test if a property exists on that node. If, however, that XML document has namespaces, you have to do extra setup with the XML document so that you can find the node. This function does that work for you.
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
Xml | XmlDocument | The XML document to check. |
true | false | |
XPath | String | The XPath expression for the node to check. |
true | false | |
DefaultNamespacePrefix | String | The short prefix for the document's default namespace, if any. |
false | false | |
Message | String | The message to describe the failure if the assertion fails. |
false | false |
' '/foo/bar/biz'
Demonstrates how to assert that an XML document doesn't contain a node.