xml_converter 1.0.0 copy "xml_converter: ^1.0.0" to clipboard
xml_converter: ^1.0.0 copied to clipboard

The XML Converter is a Dart package that provides functionality to convert XML strings to JSON format and Dart classes,This package is designed to facilitate the handling of XML data in Dart applicati [...]

example/xml_converter_example.dart

import 'package:xml_converter/xml_converter.dart';

void main() async {
  final xmlString = '''
  <user>
    <name>ahmed talal</name>
    <age>26</age>
  </user>
  ''';

  final converter = XmlConverterBase();

  // Convert XML string to JSON file
  await converter.convertXmlToJsonFile(xmlString, 'user_data');

  // Convert XML string to Dart class file
  await converter.convertXmlToDartClass(xmlString, 'User', 'user_class');

// the output like this :
// JSON file generated at: lib/generated/user_data.json
// Dart class generated at: lib/generated/user_class.dart

  /*
      class User {
      String? name;
      String? age;
      User({
        this.name,
        this.age,
      });

      User.fromJson(Map<String, dynamic> json) {
        name = json["name"] ?? "";
        age = json["age"] ?? "";
      }

      Map<String, dynamic> toJson() => {
        "name": name ?? "",
        "age": age ?? "",
      };
    }
  */

  /* 
  {
  "name":"ahmed talal",
  "age":"26"
  }
  */
}
0
likes
0
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

The XML Converter is a Dart package that provides functionality to convert XML strings to JSON format and Dart classes,This package is designed to facilitate the handling of XML data in Dart applications by offering a simple and efficient way to transform XML into usable formats.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

xml

More

Packages that depend on xml_converter