Reputation: 3207
There is any way in Dart to parse XML and obtain an object?
For example if I have this XML:
<person>
<name>John</name>
<surname>Smith</surname>
</person>
I want to bind it to this object:
class Person {
String name;
String surname;
...
}
With a snippet like this:
Person person = parse(xml);
Upvotes: 5
Views: 876
Reputation: 41
I made a pub package that transforms xml to objects with objectbuilders. Maybe that is what you are searching for! https://github.com/jorishermans/xmlstream
You always need to tell the system how you want to transform your xml to the dart object.
Upvotes: 1
Reputation: 657546
Not out of the box.
Here is currently an extensive discussion going on about serialization/deserialization: https://groups.google.com/a/dartlang.org/forum/#!topic/misc/0pv-Uaq8FGI
The discussion is mostly about JSON but most of it applies to XML as well.
Upvotes: 3