Coder Social home page Coder Social logo

Comments (2)

Mingun avatar Mingun commented on August 17, 2024

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.

mmittnacht avatar mmittnacht commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.