---
title: "XML: \"There is no Unicode byte order mark. Cannot switch to Unicode.\""
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/160071-xml-there-is-no-unicode-byte-order-mark-cannot-switch-to-unicode"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "Lukaspojken"
published: "2007-05-09T04:36:27.000Z"
updated: "2007-05-09T08:34:13.000Z"
replies: 1
views: 338
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/160071-xml-there-is-no-unicode-byte-order-mark-cannot-switch-to-unicode"
---

# XML: "There is no Unicode byte order mark. Cannot switch to Unicode."

## #1 — Lukaspojken, 2007-05-09T04:36Z

När jag försöker på ett enkelt sätt läsa en xmlfil så får jag detta fel: "There is no Unicode byte order mark. Cannot switch to Unicode." Någon som vet vad jag gör för fel?

```
Dim xmlReader As New System.Xml.XmlTextReader("C:\temp\xmltest.xml")

Dim strValues As String = ""
While xmlReader.Read() 'På den här raden smäller det
    xmlReader.MoveToContent()
    strValues &= xmlReader.Value
End While

xmlReader.Close()
```

Så här ser xml:en ut:

```
<?xml version="1.0" encoding="utf-16"?>
<Block>
  <message sender="Test" />
  <Data text="Test" />
</Block>
```

Permalänk: https://www.webforum.nu/p/160071

## #2 — Lukaspojken, 2007-05-09T08:34Z

En omsparning av xml-filen i unicode löste det :)

Permalänk: https://www.webforum.nu/p/1973057

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/160071-xml-there-is-no-unicode-byte-order-mark-cannot-switch-to-unicode
