import 'package:xml/xml.dart';
import 'package:xml_annotation/xml_annotation.dart' as annotation;
import 'title.dart';
part 'book.g.dart';
@annotation.XmlRootElement(name: 'book')
@annotation.XmlSerializable()
class Book {
@annotation.XmlElement(name: 'title')
Title? title;
@annotation.XmlElement(name: 'author')
List<String>? authors;
@annotation.XmlElement(name: 'price', isSelfClosing: false)
String? price;
Book({
this.title,
this.authors,
this.price,
});
factory Book.fromXmlElement(XmlElement element) =>
_$BookFromXmlElement(element);
@override
String toString() {
return 'Book{title: $title, authors: $authors, price: $price}';
}
void buildXmlChildren(
XmlBuilder builder, {
Map<String, String> namespaces = const {},
}) =>
_$BookBuildXmlChildren(
this,
builder,
namespaces: namespaces,
);
void buildXmlElement(
XmlBuilder builder, {
Map<String, String> namespaces = const {},
}) =>
_$BookBuildXmlElement(
this,
builder,
namespaces: namespaces,
);
List<XmlAttribute> toXmlAttributes({
Map<String, String?> namespaces = const {},
}) =>
_$BookToXmlAttributes(
this,
namespaces: namespaces,
);
List<XmlNode> toXmlChildren({
Map<String, String?> namespaces = const {},
}) =>
_$BookToXmlChildren(
this,
namespaces: namespaces,
);
XmlElement toXmlElement({
Map<String, String?> namespaces = const {},
}) =>
_$BookToXmlElement(
this,
namespaces: namespaces,
);
}
Originally posted by @nvi9 in #66