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.   


  3. #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

  4. #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

  5. #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

  6. #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 PowerShell
deserialize objects via import-clixml PowerShell
Formatting Inline for Export-CliXML Command PowerShell
Export/Import-CliXml oddity PowerShell
export-clixml and compare-object question PowerShell