none
"There is no unicode byte order mark:cannot switch to unicode" error while loading with XmlDocument clas

    Question

  • I'm trying to load the Application.MyApp file and am using Visual Studio 2005 june ctp. This file is a new file generated by visual studio and is the "code behind" all VB Projects in VS 2005. I need to load this file and retreive a piece of information i cant seem to find anywhere else, but I'm running into this error! This error pops when I execute the doc.Load(filename) member.

    is there a way to force it to use a specific byte order? I find nothing in the XmlDocument class that looks like it might effect this.

    Thanks in advance

    Bill


    The file looks like:

    <?xml version="1.0" encoding="utf-8"?>

    <MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <MySubMain>true</MySubMain>

    <MainForm>Form1</MainForm>

    <SingleInstance>false</SingleInstance>

    <ShutdownMode>0</ShutdownMode>

    <EnableVisualStyles>true</EnableVisualStyles>

    <AuthenticationMode>0</AuthenticationMode>

    <ApplicationType>0</ApplicationType>

    <SaveMySettingsOnExit>true</SaveMySettingsOnExit>

    </MyApplicationData>

    Friday, August 12, 2005 10:10 PM

Answers

  • Usually it happens when you have ANSI (or any one byte) encoded file with xml header
    <?xml version="1.0" encoding="utf-16" ?>

    Hack: you can read this file into string and use LoadXml()
    Thursday, August 18, 2005 3:21 AM

All replies

  • Usually it happens when you have ANSI (or any one byte) encoded file with xml header
    <?xml version="1.0" encoding="utf-16" ?>

    Hack: you can read this file into string and use LoadXml()
    Thursday, August 18, 2005 3:21 AM
  • You can also get errors the other way, when the file starts with unicode byte order mark (FF FE) but then contains a different encoding attribute.

    Friday, August 26, 2005 8:00 AM
  • hi..

     

    it can b solved if u just remove encoding attribute from PI(processing instruction ),ie, xml tag in your xsl file...

    instead of this...

    <?xml version="1.0" encoding="utf-16"?>

    go for

    <?xml version="1.0" ?>

    in xsl file....

    • Proposed as answer by sagar T.U. _ Tuesday, March 30, 2010 2:02 PM
    Tuesday, March 30, 2010 2:01 PM