• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Import-CliXml error

D

David Trimboli

#1
I'm trying to import an XML file to a variable, and I get the following
error:


% $client = import-clixml Client_Suddenlink-NewHire_Export-20080421.xml
Import-Clixml : Element 'Objs' with namespace name
'http://schemas.microsoft.com/powershell/2004/04' was not found. Lin
e 1, position 40.
At line:1 char:24
+ $client = import-clixml <<<<
Client_Suddenlink-NewHire_Export-20080421.xml


I can't post the entire XML file, but I can post the first line, which
is what is causing the cmdlet to stop:

<?xml version="1.0" encoding="UTF-8"?><VisionDataExchange xmlns:xsi =
"http://www.w3.org/2001/XMLSchema-instance">

Can anyone tell me what's wrong here?

--
David
Stardate 8486.3
 

My Computer

O

/\\/\\o\\/\\/

#2
import-cliXML is not for "general" XML reading but for de-seralizing
PowerSHell objects seralized with export-CliXMLin a "special" PowerShell XML
format (schema) (hence the CLI command line interface) in the name

You need to use PowerShell's XML support for this kind of tasks :

try :

$client = [xml](get-content Client_Suddenlink-NewHire_Export-20080421.xml)

enjoy,

Greetings /\/\o\/\/
http://thePowerShellGuy.com

"David Trimboli" <trimboli@xxxxxx> wrote in message
news:%23AMaK251IHA.3884@xxxxxx

> I'm trying to import an XML file to a variable, and I get the following
> error:
>
>
> % $client = import-clixml Client_Suddenlink-NewHire_Export-20080421.xml
> Import-Clixml : Element 'Objs' with namespace name
> 'http://schemas.microsoft.com/powershell/2004/04' was not found. Lin
> e 1, position 40.
> At line:1 char:24
> + $client = import-clixml <<<<
> Client_Suddenlink-NewHire_Export-20080421.xml
>
>
> I can't post the entire XML file, but I can post the first line, which is
> what is causing the cmdlet to stop:
>
> <?xml version="1.0" encoding="UTF-8"?><VisionDataExchange xmlns:xsi =
> "http://www.w3.org/2001/XMLSchema-instance">
>
> Can anyone tell me what's wrong here?
>
> --
> David
> Stardate 8486.3
 

My Computer

D

David Trimboli

#3
Oh! Silly me! Thanks, Shay.

David
Stardate 8486.4

Shay Levi wrote:

> To import your own XML files, try:
>
> PS > $xml = [xml] (get-content
> Client_Suddenlink-NewHire_Export-20080421.xml)
> PS > $xml
>
> DT> I'm trying to import an XML file to a variable, and I get the
> DT> following error:
> DT> DT> % $client = import-clixml
> DT> Client_Suddenlink-NewHire_Export-20080421.xml
> DT> Import-Clixml : Element 'Objs' with namespace name
> DT> 'http://schemas.microsoft.com/powershell/2004/04' was not found. Lin
> DT> e 1, position 40.
> DT> At line:1 char:24
> DT> + $client = import-clixml <<<<
> DT> Client_Suddenlink-NewHire_Export-20080421.xml
> DT> I can't post the entire XML file, but I can post the first line,
> DT> which is what is causing the cmdlet to stop:
> DT> DT> <?xml version="1.0" encoding="UTF-8"?><VisionDataExchange xmlns:xsi
> DT> = "http://www.w3.org/2001/XMLSchema-instance">
> DT> DT> Can anyone tell me what's wrong here?
> DT>
>
 

My Computer

K

Karl Prosser[MVP]

#4
import-clixml isn't for importing general XML files.. Its for importing
serialized powershell objects that were generated from export-clixml

to load an XML file you can simply load its strings, then cast it to an
XmlDocument

i.e

$a = [xml](get-content myfile.xml)


David Trimboli wrote:

> I'm trying to import an XML file to a variable, and I get the following
> error:
>
>
> % $client = import-clixml Client_Suddenlink-NewHire_Export-20080421.xml
> Import-Clixml : Element 'Objs' with namespace name
> 'http://schemas.microsoft.com/powershell/2004/04' was not found. Lin
> e 1, position 40.
> At line:1 char:24
> + $client = import-clixml <<<<
> Client_Suddenlink-NewHire_Export-20080421.xml
>
>
> I can't post the entire XML file, but I can post the first line, which
> is what is causing the cmdlet to stop:
>
> <?xml version="1.0" encoding="UTF-8"?><VisionDataExchange xmlns:xsi =
> "http://www.w3.org/2001/XMLSchema-instance">
>
> Can anyone tell me what's wrong here?
>
 

My Computer

S

Shay Levi

#5
Hi David,


Are you trying to import your *own* XML files?

You use the Export-CliXml cmdlet to serialize a .NET object/collection into
an XML file. You can read it back into an object using the Import-CliXml
cmdlet.
For more help and usage examples, type:

PS > help Import-Clixml -full
PS > help Export-Clixml -full



BTW, the first line of exported file (using export-clixml) should look like:

<Objs Version="1.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">...




To import your own XML files, try:

PS > $xml = [xml] (get-content Client_Suddenlink-NewHire_Export-20080421.xml)
PS > $xml




---
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com

DT> I'm trying to import an XML file to a variable, and I get the
DT> following error:
DT>
DT> % $client = import-clixml
DT> Client_Suddenlink-NewHire_Export-20080421.xml
DT> Import-Clixml : Element 'Objs' with namespace name
DT> 'http://schemas.microsoft.com/powershell/2004/04' was not found. Lin
DT> e 1, position 40.
DT> At line:1 char:24
DT> + $client = import-clixml <<<<
DT> Client_Suddenlink-NewHire_Export-20080421.xml
DT> I can't post the entire XML file, but I can post the first line,
DT> which is what is causing the cmdlet to stop:
DT>
DT> <?xml version="1.0" encoding="UTF-8"?><VisionDataExchange xmlns:xsi
DT> = "http://www.w3.org/2001/XMLSchema-instance">
DT>
DT> Can anyone tell me what's wrong here?
DT>
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)