5

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);

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.