Giter Club home page Giter Club logo

Comments (6)

suntong avatar suntong commented on May 30, 2024

I tried to convert that file to ascii myself, but got into the following problem when doing ReadFrom():

xml: encoding "utf-16" declared but Decoder.CharsetReader is nil

from etree.

suntong avatar suntong commented on May 30, 2024

Attaching the simple example.xml file for you to try it out...

example.zip

from etree.

suntong avatar suntong commented on May 30, 2024

After removing the BOM char myself, when doing ReadFrom(), I'll get:

XML syntax error on line 1: expected element name after <

"MS is the source of all evil & trouble". Yes, I totally agree.

from etree.

suntong avatar suntong commented on May 30, 2024

After removing the stupid first line <?xml version="1.0" encoding="utf-16"?>, I'm getting:

XML syntax error on line 1: illegal character code U+0000
$ head -1 et_example.xml | hexdump -C
00000000  00 3c 00 54 00 72 00 61  00 63 00 65 00 44 00 61  |.<.T.r.a.c.e.D.a|
00000010  00 74 00 61 00 20 00 78  00 6d 00 6c 00 6e 00 73  |.t.a. .x.m.l.n.s|
00000020  00 3d 00 22 00 68 00 74  00 74 00 70 00 3a 00 2f  |.=.".h.t.t.p.:./|
00000030  00 2f 00 74 00 65 00 6d  00 70 00 75 00 72 00 69  |./.t.e.m.p.u.r.i|
00000040  00 2e 00 6f 00 72 00 67  00 2f 00 54 00 72 00 61  |...o.r.g./.T.r.a|
00000050  00 63 00 65 00 50 00 65  00 72 00 73 00 69 00 73  |.c.e.P.e.r.s.i.s|
00000060  00 74 00 65 00 6e 00 63  00 65 00 2e 00 78 00 73  |.t.e.n.c.e...x.s|
00000070  00 64 00 22 00 3e 00 0d  00 0a                    |.d.".>....|
0000007a

Attaching the witched file:
et_example.zip

So, basically, if you could make this file being read as-is without any issues, that'd be super.
thanks a lot.

from etree.

beevik avatar beevik commented on May 30, 2024

It looks like you're trying to read a UTF16-encoded file. You should probably use the unicode/utf16 library to decode it, re-encode it to UTF8 using unicode/utf8, and then pass it to etree.

from etree.

beevik avatar beevik commented on May 30, 2024

Closing this issue since I haven't seen a response. Please feel free to reopen if my response doesn't help you.

from etree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.