Fedy2
Fedy2

Reputation: 3207

XML binding in Dart

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

Answers (2)

Joris Hermans
Joris Hermans

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

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

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

Related Questions