Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Test-Xml

Test-Xml

pscx.dll

Synopsis

PSCX Cmdlet: Tests for well formedness and optionally validates against XML Schema.

Syntax

Test-Xml [-Path] [-EnableDtd] [-SchemaPath] [-Validate] [<CommonParameters>]

Test-Xml [-InputObject] [-EnableDtd] [-SchemaPath] [-Validate] [<CommonParameters>]

Test-Xml [-LiteralPath] [-EnableDtd] [-SchemaPath] [-Validate] [<CommonParameters>]

Detailed Description

Tests for well formedness and optionally validates against XML Schema. It doesn't handle specifying the targetNamespace. To see validation error messages, specify the -Verbose flag.

Parameters

-LiteralPath <String[]>

Specifies a path to the item. The value of -LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Path <String[]>

Specifies the path to the file to process. Wildcard syntax is allowed.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

true

-InputObject <PSObject>

Accepts an object as input to the cmdlet. Enter a variable that contains the objects or type a command or expression that gets the objects.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

false

-EnableDtd <SwitchParameter>

Enables document type definition (DTD) processing.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-SchemaPath <String[]>

Array of paths to the required schema files to perform schema-based validation.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-Validate <SwitchParameter>

Forces schema validation of the XML against inline schema.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type


Return Type


Notes

Examples

-------------------------- EXAMPLE 1 --------------------------

Returns true or false indicating whether or not foo.xml is well-formed.

C:\PS> Test-Xml foo.xml 

-------------------------- EXAMPLE 2 --------------------------

Returns true or false indicating whether or not foo.xml is well-formed and displays any XML error info.

C:\PS> Test-Xml foo.xml -Verbose 

-------------------------- EXAMPLE 3 --------------------------

Returns true or false indicating whether or not foo.xml is well-formed and conforms to the schema defined in foo.xsd.

C:\PS> Test-Xml foo.xml -SchemaPath .\foo.xsd

-------------------------- EXAMPLE 4 --------------------------

Returns true or false indicating whether or not foo.xml is well-formed. This examples enables DTD processing for XML files that use a DTD.

C:\PS> Test-Xml foo.xml -EnableDtd

Convert-Xml
Format-Xml