Comments (2)
To change the first xml
ProcInst in an existing document, you can do this:
for _, c := range doc.Child {
if pi, ok := c.(*ProcInst); ok && pi.Target == "xml" {
pi.Inst = `version="1.0" encoding="utf-8"`
break
}
}
If you already know the first child in the document is the xml
ProcInst, then you can just do this instead:
if pi, ok := doc.Child[0].(*ProcInst); ok {
pi.Inst = `version="1.0" encoding="utf-8"`
}
Of course this will not change how any of the content in the document is actually encoded. To do that, you'll need to process every element, attribute and text field in the document, converting from gd2312
to utf-8
. I believe that's possible, but it's more work than I'm able to describe in an issue report.
from etree.
thank for your reply . i do as you say, it really works. to converting zhe every character to utf8 i have ready do it.
from etree.
Related Issues (20)
- Can you share performance benchmarks or steps to measure it for this tool? HOT 2
- Perhaps link prominently to docs? HOT 1
- Add doctype read HOT 1
- a bug of Element.Text() HOT 1
- Error Read xml ISO-8859-1 HOT 1
- can not parse xml with "&" HOT 1
- Unexpected <></> when adding outer layer HOT 3
- Expected " but " HOT 1
- go version EOL HOT 1
- how to pretty print when writing back HOT 4
- xml writeto string? HOT 1
- UTF-8 support HOT 3
- Does this library supports XInclude standards for XML document? HOT 1
- How do I remove indent between inline labels? HOT 2
- Is there any way to get the comments of a document? HOT 5
- i don't wanna the string text to be escaped, how can i achieve that HOT 5
- if my text contains some string likes '<br>',but i dont wanna to escape them,how can i do HOT 2
- XPath string literal syntax does not accept double quotes HOT 2
- Avoid panics when element doesn't exist HOT 4
- vulnerabilities HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from etree.