Comments (2)
XML Prolog (according to the specification, that's all before the root element) is not considered as XML content, so it is not mapped to serde model which works only with document content.
So it is impossible to use serde to read XML declaration as you want. You should create a Reader
, read the first event and if it is Event::Decl
, process it (maybe you would need to skip Event::Comment
and Event::Text
events, although in well-formed XML documents nothing can precede the XML declaration, so if you interested only on strictly well-formed documents, expect only Event::Decl
).
Unfortunately, it is not possible to get access to the internal reader of existing Deserializer or to create a Deserializer from existing Reader, so some work for parsing will be done twice. We are interested in improvements in that area.
from quick-xml.
Hey @Mingun
Thank you for taking time to help me with a well detailed response. In our use-case the double serialization might be sufficient enough, though I will think if I can come up with a better approach later on. Thank you very much!
from quick-xml.
Related Issues (20)
- #[serde(flatten)] not working with deserialization HOT 3
- Question: name as attribute with serde HOT 1
- `quick_xml::de::from_reader` requires a `BufRead` instead of just an `std::io::Read` HOT 2
- Change the representation of Enums HOT 7
- `memchr` vs `stringzilla` performance comparison HOT 2
- XML deserializate failed when text contains `&()_+-=;` HOT 6
- How to escape/de-descape with Serde HOT 1
- How do I make the result of changing `@attribute` to `$value` in the Newtype structure in `impl_deserialize_for_internally_tagged_enum!` work? HOT 3
- About reading output HOT 2
- Is it currently possible to get attribute value from &str without copying? HOT 1
- Getting all inner element along with it's attributes HOT 3
- Enhance Error Handling to Include Location Information HOT 1
- enum text content is (incorrectly) indented HOT 1
- Can't Deserialize struct with vec of enum. HOT 1
- Question about changing un/escape behavior
- Question about xml modes HOT 2
- Impossible Deserialization with a flattened `enum` / Custom deserializer? HOT 2
- Duplicate field error HOT 2
- Understanding empty tag behavior HOT 5
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 quick-xml.