1
- # quick-xml
1
+ # fast-xml -- successor of [ quick-xml]
2
2
3
- ![ status] ( https://github.com/tafia/quick -xml/actions/workflows/rust.yml/badge.svg )
4
- [ ![ Crate] ( https://img.shields.io/crates/v/quick -xml.svg )] ( https://crates.io/crates/quick -xml )
3
+ ![ status] ( https://github.com/Mingun/fast -xml/actions/workflows/rust.yml/badge.svg )
4
+ [ ![ Crate] ( https://img.shields.io/crates/v/fast -xml.svg )] ( https://crates.io/crates/fast -xml )
5
5
6
6
High performance xml pull reader/writer.
7
7
@@ -10,17 +10,27 @@ The reader:
10
10
- is easy on memory allocation (the API provides a way to reuse buffers)
11
11
- support various encoding (with ` encoding ` feature), namespaces resolution, special characters.
12
12
13
- [ docs.rs] ( https://docs.rs/quick -xml )
13
+ [ docs.rs] ( https://docs.rs/fast -xml )
14
14
15
15
Syntax is inspired by [ xml-rs] ( https://github.com/netvl/xml-rs ) .
16
16
17
+ ## Migration from [ quick-xml]
18
+
19
+ If you using quick-xml 0.22.0 or 0.23.0-alpha3, you can just replace ` quick-xml `
20
+ in your ` Cargo.toml ` with ` fast-xml ` . Replace each occurrence of ` quick_xml `
21
+ crate name to ` fast_xml ` in your code base.
22
+
23
+ That two releases of fast-xml was specifically made for migration and contains
24
+ the same code as original quick-xml, except updated cargo metadata and extern
25
+ crate names in tests, benches and examples.
26
+
17
27
## Example
18
28
19
29
### Reader
20
30
21
31
``` rust
22
- use quick_xml :: Reader ;
23
- use quick_xml :: events :: Event ;
32
+ use fast_xml :: Reader ;
33
+ use fast_xml :: events :: Event ;
24
34
25
35
let xml = r # " <tag1 att1 = "test">
26
36
<tag2><!--Test comment-->Test</tag2>
64
74
### Writer
65
75
66
76
``` rust
67
- use quick_xml :: Writer ;
68
- use quick_xml :: Reader ;
69
- use quick_xml :: events :: {Event , BytesEnd , BytesStart };
77
+ use fast_xml :: Writer ;
78
+ use fast_xml :: Reader ;
79
+ use fast_xml :: events :: {Event , BytesEnd , BytesStart };
70
80
use std :: io :: Cursor ;
71
81
use std :: iter;
72
82
@@ -110,20 +120,20 @@ assert_eq!(result, expected.as_bytes());
110
120
111
121
## Serde
112
122
113
- When using the ` serialize ` feature, quick -xml can be used with serde's ` Serialize ` /` Deserialize ` traits.
123
+ When using the ` serialize ` feature, fast -xml can be used with serde's ` Serialize ` /` Deserialize ` traits.
114
124
115
125
Here is an example deserializing crates.io source:
116
126
117
127
``` rust
118
128
// Cargo.toml
119
129
// [dependencies]
120
130
// serde = { version = "1.0", features = [ "derive" ] }
121
- // quick -xml = { version = "0.21 ", features = [ "serialize" ] }
131
+ // fast -xml = { version = "0.22 ", features = [ "serialize" ] }
122
132
extern crate serde;
123
- extern crate quick_xml ;
133
+ extern crate fast_xml ;
124
134
125
135
use serde :: Deserialize ;
126
- use quick_xml :: de :: {from_str, DeError };
136
+ use fast_xml :: de :: {from_str, DeError };
127
137
128
138
#[derive(Debug , Deserialize , PartialEq )]
129
139
struct Link {
@@ -213,10 +223,12 @@ fn crates_io() -> Result<Html, DeError> {
213
223
214
224
### Credits
215
225
216
- This has largely been inspired by [ serde-xml-rs] ( https://github.com/RReverser/serde-xml-rs ) .
217
- quick -xml follows its convention for deserialization, including the
226
+ This has largely been inspired by [ serde-xml-rs] ( https://github.com/RReverser/serde-xml-rs ) .
227
+ fast -xml follows its convention for deserialization, including the
218
228
[ ` $value ` ] ( https://github.com/RReverser/serde-xml-rs#parsing-the-value-of-a-tag ) special name.
219
229
230
+ Original [ quick-xml] was developed by @tafia and abandoned around end of 2021.
231
+
220
232
### Parsing the "value" of a tag
221
233
222
234
If you have an input of the form ` <foo abc="xyz">bar</foo> ` , and you want to get at the ` bar ` , you can use the special name ` $value ` :
@@ -262,7 +274,7 @@ Serializing `Root { foo: Foo::Bar }` will then yield `<Root foo="Bar"/>` instead
262
274
263
275
### Performance
264
276
265
- Note that despite not focusing on performance (there are several unecessary copies), it remains about 10x faster than serde-xml-rs.
277
+ Note that despite not focusing on performance (there are several unnecessary copies), it remains about 10x faster than serde-xml-rs.
266
278
267
279
# Features
268
280
@@ -273,7 +285,8 @@ Note that despite not focusing on performance (there are several unecessary copi
273
285
274
286
Benchmarking is hard and the results depend on your input file and your machine.
275
287
276
- Here on my particular file, quick-xml is around ** 50 times faster** than [ xml-rs] ( https://crates.io/crates/xml-rs ) crate.
288
+ Here on my particular file, fast-xml is around ** 50 times faster** than [ xml-rs] ( https://crates.io/crates/xml-rs ) crate.
289
+ _ (measurements was done while this crate named quick-xml)_
277
290
278
291
```
279
292
// quick-xml benches
@@ -298,3 +311,5 @@ Any PR is welcomed!
298
311
## License
299
312
300
313
MIT
314
+
315
+ [ quick-xml ] : https://github.com/tafia/quick-xml
0 commit comments