< Back
Import-XmlToSql
Post
NAME Import-XmlToSql
SYNOPSIS
DImport an xml to sql table
SYNTAX
Import-XmlToSql -SqlServer <String> -DatabaseName <String> [-Username <String>] [-Password <SecureString>]
-TableName <String> -XmlFile <String> -Mapping <Hashtable> [<CommonParameters>]
Import-XmlToSql -ConnectionString <String> -TableName <String> -XmlFile <String> -Mapping <Hashtable>
[<CommonParameters>]
DESCRIPTION
Import xml to sql table
PARAMETERS
-SqlServer <String>
Sql server instance
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DatabaseName <String>
Database name
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Username <String>
Username for sql server instance. If this value is null, we consider as being Integrated Security = true
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Password <SecureString>
Password for sql server instance.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ConnectionString <String>
ConnectionString to sql server.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-TableName <String>
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-XmlFile <String>
Path to xml that has to be imported
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Mapping <Hashtable>
A hashtable that contains the mapping of node/attribute to column table. The form of this table should be:
'pathToNode'='columnName'
Required? true
Position? named
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 --------------------------
PS C:\\>Map a xml node inner text to a column named column1
Xml:
<a>
<b>
<c>Test</c>
</b>
</a>
Import-XmlToSql -ConnectionString "connectionString" -XmlFile "xmlFilePath" -Mapping @{"a.b.c"="Column1"}
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Map a xml node attribute attr to a column named column2
Xml:
<a>
<b attr="aa">
<c>Test</c>
</b>
</a>
Import-XmlToSql -ConnectionString "connectionString" -XmlFile "xmlFilePath" -Mapping @{"a.b[attr]"="Column2"}
RELATED LINKS
SYNOPSIS
DImport an xml to sql table
SYNTAX
Import-XmlToSql -SqlServer <String> -DatabaseName <String> [-Username <String>] [-Password <SecureString>]
-TableName <String> -XmlFile <String> -Mapping <Hashtable> [<CommonParameters>]
Import-XmlToSql -ConnectionString <String> -TableName <String> -XmlFile <String> -Mapping <Hashtable>
[<CommonParameters>]
DESCRIPTION
Import xml to sql table
PARAMETERS
-SqlServer <String>
Sql server instance
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DatabaseName <String>
Database name
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Username <String>
Username for sql server instance. If this value is null, we consider as being Integrated Security = true
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Password <SecureString>
Password for sql server instance.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ConnectionString <String>
ConnectionString to sql server.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-TableName <String>
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-XmlFile <String>
Path to xml that has to be imported
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Mapping <Hashtable>
A hashtable that contains the mapping of node/attribute to column table. The form of this table should be:
'pathToNode'='columnName'
Required? true
Position? named
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 --------------------------
PS C:\\>Map a xml node inner text to a column named column1
Xml:
<a>
<b>
<c>Test</c>
</b>
</a>
Import-XmlToSql -ConnectionString "connectionString" -XmlFile "xmlFilePath" -Mapping @{"a.b.c"="Column1"}
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Map a xml node attribute attr to a column named column2
Xml:
<a>
<b attr="aa">
<c>Test</c>
</b>
</a>
Import-XmlToSql -ConnectionString "connectionString" -XmlFile "xmlFilePath" -Mapping @{"a.b[attr]"="Column2"}
RELATED LINKS