Comments (5)
Unfortunately, this is how it's intended to work (at the moment). Serde's Deserializer trait is designed to work on streams and report items back as soon as they're found, so we can report only consecutive same-typed items as array. Otherwise, we would have to end up with keeping HashMap-based tree of entire XML before sending anything to Serde which would be quite expensive.
from serde-xml-rs.
I understand. I am trying to parse wsdl files like this one: http://www.webservicex.com/CurrencyConvertor.asmx?wsdl
And even in that small example the schema structure has an element which is followed by a simpleType and then two elements again.
Do you know of a workaround?
Wouldn't holding information about the leaf and references to the parent chain be enough?
from serde-xml-rs.
Huh, I truly hoped such examples don't exist in real-world :(
Wouldn't holding information about the leaf and references to the parent chain be enough?
The way I see, you need to always collect all children first before being able to report arrays to Serde (as you need to have both start and end when you do that). Which means that for each of their children you also need to deserialize their children first. And so on and so on... If you have a version which wouldn't involve such recursion, I'd happily accept a PR, it's just that personally I don't know how to do that without losing efficiency for other 95% of cases.
Do you know of a workaround?
Not sure if this works for you, but you can either 1) declare enum
and parse all children into such enum (where tag name is enum variant name and contents are, well, contents) or 2) you can implement custom deserialize function for such structure manually and use with Serde's deserialize_with
attribute.
from serde-xml-rs.
Hi, thank you for great rust xml tool!
I have the same problem while writing my project.
The data is like below,
<link />
<joint />
<link />
<joint />
<link />
<joint />
and I want vector of link, and vector of joint.
If some one already solved this problem, could you show me how to handle it?
That will help Rust/serde beginner like me!
from serde-xml-rs.
This looks to be the same problem as:
Repeated, Interleaved Tags are not working currently with serde.
I made a proof of concept that will solve this. But it is not stable in any sense.
#55
serde-rs/serde#1725
https://github.com/ralpha/serde_deserializer_best_effort
from serde-xml-rs.
Related Issues (20)
- Custom { field: "missing field `soap:Body`" } when colon used
- LastElementNameNotAvailable error on writing HOT 11
- Decoding 0 elements in to a Vec gives "custom: missing field `$value`" error HOT 2
- Deserialization with custom deserializer does not work according to serde spec HOT 1
- Is there something like "from_slice"
- custom: missing field `id`
- Expose EmitterConfig/Make document declaration optional
- readme.md example broken out of the box
- readme.md example broken out of the box
- Can't serialize a struct with error 'LastElementNotAvailable'
- Error `DocumentStartAlreadyEmitted` while trying to serialize simple structure in 0.6.0
- Hoot serialize into attributes HOT 2
- Cannot add attribute id
- duplicate field `$value`'
- Does anyone have an improved fork or does any better alternative exist?
- You've found a bug in xml-rs, caused by calls to push_pos() in states that don't end up emitting events
- Regression : Fix xml-rs depencency version in Cargo.toml
- error order when serde a enum field
- Parse error whlist parsing hackernoon xml feed
- Enum/choice list does not work HOT 1
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 serde-xml-rs.