3

I am trying to utilize an xml document but am running into this error:

Invalid byte 3 of 3-byte UTF-8 sequence

My document looks something like this below but with more tags and content. Please do not focus on the document below though. I use several documents with this format. I believe it is a character in my document thats invalid but I just don't know the best way to find it because it is so large.

Any ideas or tools I could use? Thanks.

THanks!

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "file:C:/Documentum/Viewed/map.dtd">
<map xmlns:dctm="http://www.documentum.com" dctm:obj_status="Read-Only" dctm:obj_id="09002af8800af696" dctm:version_label="CURRENT" xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/">
    <title>Overview of the Commercial General Liability (CGL) Insurance Coverages  </title><moreTagsHere><!-- more tags here... --></moreTagsHere>
</map>
1
  • What application are you using to generate the document? What application are you using to "utilize" the document?
    – heavyd
    Aug 21, 2009 at 20:47

6 Answers 6

2

There was an invalid curly quote in my xml.

0
0

I'd try XMLStarlet:

[...] XMLStarlet is a set of command line utilities (tools) which can be used to transform, query, validate, and edit XML documents and files using simple set of shell commands in similar way it is done for plain text files using UNIX grep, sed, awk, diff, patch, join, etc commands. [...]
[emphasis mine]

0

I have a sneaking suspicion you may be using a tool by Microsoft.

In my experience Expression Web used to place header information in text files to identify them as what ever format they were - nothing else recognized them, and they showed up as random characters. This was particularly an issue with PHP as it broke includes.

0

Forget the fact it's XML, you need to validate the UTF-8. Maybe simply open up in Firefox and search for the � character? Otherwise see UTF-8 validation on Stack Overflow.

0

You've probably used an editor that adds a Byte Order Mark (BOM) to the file. many/most xml editors/website editors allows you to save the document with/without the bom. Check the save options in whatever editor you've been using.

You probably need to remove the BOM to avoid the error.

If your editor doesn't support that option I can recommend the excellent Notepad++

3
  • I've never seen the UTF-8 BOM forbidden by the XML specs (and surely other BOMs are perfectly fine). In fact, auto-detecting is documented to allow using a BOM, though it's not required as a parser should know how to detect the first <xml? sequence -- w3.org/TR/2006/REC-xml-20060816/#sec-guessing
    – Arjan
    Aug 22, 2009 at 7:53
  • My bad, updated the post to remove the incorrect information. I have a memory of getting errors on the bom though. Is it the xhtml specs that might disallow it?
    – Paxxi
    Aug 22, 2009 at 9:19
  • Maybe you had a BOM in some true Unicode String value itself? Or in a database value? Or when transferring over HTTP using Content-Type text/xml then the (authoritative) charset defaults to US-ASCII per ietf.org/rfc/rfc2046, hence a processor should ignore (or maybe even disallow; see ietf.org/rfc/rfc2376) a BOM when the charset is not specified. (Using application/xml rather than text/xml solves that default US-ASCII, but of course one should simply specify the charset to start with.)
    – Arjan
    Aug 22, 2009 at 12:29
0

If you're using tomcat you proably need to set up the encoding, I am using tomcat as a service in Windows and in the configuration options the following commmand did the trick for me:

Dfile.encoding=UTF-8

Hope it helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .