cocool97 / xml-builder Goto Github PK
View Code? Open in Web Editor NEWRust crate providing an easy way to build XML documents
Rust crate providing an easy way to build XML documents
This code generate bad XML
use xml_builder::{XMLBuilder, XMLElement, XMLVersion};
fn main() {
let mut xml = XMLBuilder::new()
.version(XMLVersion::XML1_1)
.encoding("utf-8".into())
.build();
let mut text = XMLElement::new("text");
text.add_text(r#"&"'<>"#.into()).unwrap();
xml.set_root_element(text);
let mut writer = Vec::new();
xml.generate(&mut writer).unwrap();
let _str = String::from_utf8(writer).unwrap();
print!("{}", _str)
}
result:
<?xml version="1.1" encoding="utf-8"?>
<text>&"'<></text>
expect:
<?xml version="1.1" encoding="utf-8"?>
<text>&"'<></text>
I think it is not reasonable behavior for users to have to perform escaping manually.
Since XmlError
is explicitly the crates error type it should implement the trait which communicates that across the eco system, namely the trait std::error::Error
Hi! I've been wondering whether the data written to the writer
passed to generate
/render
only contains valid UTF8. I couldn't find any documentation, but from briefly looking at the code, it does seem like it? In that case, could one change the trait bound to fmt::Write
? That would allow passing String
s to the methods.
I suppose this has something to do with #7?
Currently encoding
attribute exists, but its value does not make changes on final XML document
XML documentation makes it optional, should apply it.
standalone
fields should be added as optional.
let mut xml = XMLBuilder::new()
.version(XMLVersion::XML1_0)
.encoding("utf-8".into())
.standalone(Some(true))
.build();
Produces:
<?xml version="1.0" encoding="utf-8" standalone="true"?>
Which is invalid XML.
As stated in XML specification, one or many DOCTYPE
elements are allowed right after the prolog
Add a feature no-std that use #[no-std] so the library can be used in embedded systems
Could add the possibility to display comments in an outgoing XML document
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.