Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the php parsing xml prompt Invalid byte 1 of 1-byte UTF-8 sequence error

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to solve the php parsing xml prompt Invalid byte 1 of 1-byte UTF-8 sequence error", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's train of thought slowly in depth, together to study and learn "how to solve php parsing xml prompt Invalid byte 1 of 1-byte UTF-8 sequence error" bar!

Error prompt

Invalid byte 1 of 1-byte UTF-8 sequence

Cause analysis

In the Chinese version of window, the default encoding of java is GBK, that is, although we identified the xml to be saved as utf-8 format, the file is actually saved in GBK format, so this is why we can use GBK, GB2312 encoding to generate xml files can be parsed correctly, while files generated in UTF-8 format cannot be parsed by xml parsers.

Change the value of the encoding attribute UTF-8 of xml to UTF8

Org.xml.sax.SAXParseException: Content is not allowed in trailing section

Parsing the first and the string trim () will solve the problem.

Resolve:

1. The simplest thing is to change it to

2. Or change the character set to UTF-8 when xml is opened and saved.

Or change the procedure.

The copy code is as follows:

SAXReader reader = new SAXReader ()

Org.dom4j.Document document = reader.read ("D:\ ha.xml")

OutputFormat of = new OutputFormat ()

Of.setEncoding ("UTF-8"); / / change the encoding method

XMLWriter writer = new XMLWriter (new FileWriter "d:\ dom4j.xml"), of)

Thank you for your reading, the above is "how to solve php parsing xml prompt Invalid byte 1 of 1-byte UTF-8 sequence error" content, after the study of this article, I believe you on how to solve php parsing xml prompt Invalid byte 1 of 1-byte UTF-8 sequence error this problem has a more profound experience, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report