Windows Vista Forums

Import-CliXml error

  1. #1


    David Trimboli Guest

    Import-CliXml error

    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 System SpecsSystem Spec

  2. #2


    /\\/\\o\\/\\/ Guest

    Re: Import-CliXml error

    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 System SpecsSystem Spec

  3. #3


    David Trimboli Guest

    Re: Import-CliXml error

    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 System SpecsSystem Spec

  4. #4


    Karl Prosser[MVP] Guest

    Re: Import-CliXml error


    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 System SpecsSystem Spec

  5. #5


    Shay Levi Guest

    Re: Import-CliXml error

    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 System SpecsSystem Spec

Import-CliXml error

Similar Threads
Thread Forum
Export-clixml producing weird xml output
I have the following code: $regex = "(\d{3,4})" $query = Get-ChildItem -Recurse | Where-Object {$_.Name -match $regex} | ? {$_.psIsContainer} |...
PowerShell
Re: Import-CSV getting Error
Mmm since this is the year of data parsing and charting! FYI LogParser.exe -h -i:csv Returns Input format: CSV (CSV Format) Parses text...
PowerShell
deserialize objects via import-clixml
Hi, I'm just doing my first steps in developing custom cmdlets. I have a first cmdlet which writes objects of type Document. So I have something...
PowerShell
Formatting Inline for Export-CliXML Command
Two things... First.. you dont want to use select.. use foreach-object $log | foreach-object{$_.Message -replace "'", ""} | export-clixml ...
PowerShell
Export/Import-CliXml oddity
I'm saving out the results of Get-Command like so: gcm -type alias, filter, function, cmdlet | export-clixml > commands.xml I then load that...
PowerShell
export-clixml and compare-object question
I'm trying to compare a "living" object with one imported using import-clixml, but compare-object is not seeing them as identical. See code: PS...
PowerShell
Export-Clixml output is inconvenient for viewing
Export-Clixml writes all the data as the only line of text (well, except line breaks in the data). It is inconvenient for viewing of the output...
PowerShell