< Back
Assert-NodeDoesNotExist
Post
NAME Assert-NodeDoesNotExist
SYNOPSIS
Asserts that a node doesn't exist in an XML document.
SYNTAX
Assert-NodeDoesNotExist [-Xml] <XmlDocument> [-XPath] <String> [[-DefaultNamespacePrefix] <String>] [[-Message]
<String>] [<CommonParameters>]
DESCRIPTION
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.
PARAMETERS
-Xml <XmlDocument>
The XML document to check.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-XPath <String>
The XPath expression for the node to check.
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DefaultNamespacePrefix <String>
The short prefix for the document's default namespace, if any.
Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Message <String>
The message to describe the failure if the assertion fails.
Required? false
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
Assert-NodeDoesNotExist '<foo><bar><baz /></bar></foo>' '/foo/bar/biz'
Demonstrates how to assert that an XML document doesn't contain a node.
RELATED LINKS
Assert-NodeExists
Test-NodeExists
SYNOPSIS
Asserts that a node doesn't exist in an XML document.
SYNTAX
Assert-NodeDoesNotExist [-Xml] <XmlDocument> [-XPath] <String> [[-DefaultNamespacePrefix] <String>] [[-Message]
<String>] [<CommonParameters>]
DESCRIPTION
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.
PARAMETERS
-Xml <XmlDocument>
The XML document to check.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-XPath <String>
The XPath expression for the node to check.
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DefaultNamespacePrefix <String>
The short prefix for the document's default namespace, if any.
Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Message <String>
The message to describe the failure if the assertion fails.
Required? false
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
Assert-NodeDoesNotExist '<foo><bar><baz /></bar></foo>' '/foo/bar/biz'
Demonstrates how to assert that an XML document doesn't contain a node.
RELATED LINKS
Assert-NodeExists
Test-NodeExists