xml2json 3.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 92

xml2json

Build Status

An XML to JSON conversion package.

This package allows the parsing of XML strings and the transformation of the resulting parse tree into the following XML JSON conventions :-

  1. Parker
  2. Badgerfish
  3. Google Data(GData).

The package uses the xml parser to peform the parsing of XML data into a parse tree.

Exact transforming rules can be found in the 'Transforming Details' document in the docs folder.

The Parker convention is a lossy but lean conversion from XML into JSON, ideal for lightweight XML parsing of collections of books, records etc. where attributes and namespace information is not needed.

Badgerfish and GData both preserve XML information such as attributes and namespaces. These are more suited to heavyweight XML parsing of say ATOM feeds where this information may be needed.

See the main Xml2Json class for usage.

3.0.3

Update testing, new linter rules

3.0.2

Update testing, run browser tests on Travis

3.0.1

Issue 15, relax sdk constraints for flutter

3.0.0

Issue 14, update to Dart 2

2.0.14

Issue 12, update to latest XML package

2.0.13

Issue 11, exception message bug

2.0.12

Remove dev infinity constraint on the Dart SDK for Flutter

2.0.11

Pub updates

2.0.10

Rename the analysis options file

2.0.9

Issue 9, SDK version constraint update, general pre Dart 2.0 spruce up

2.0.8

Issue 8, correctly escape CDATA strings for JSON

2.0.7

Issue 7, CDATA nodes now translated for Badgerfish and GData.

2.0.6

Use the new XML Package, update to latest Petit Parser see issue 5 in github.

Remove Drone IO integration, now done by pub.

2.0.5

Integrate with Dart's Drone IO testing

2.0.4

Browser is now a dev dependancy

2.0.3

Fixes for Dart V1.5 usage

2.0.2

Remove references to runtime type

2.0.1

Update dependencies to latest

2.0.0

Updates for Dart 1.0 release

1.1.0

  • Fix the runtime type name change intoroduced in Dart r28101
  • Generate API documents
  • Package formatting updates

example/xml2json.dart

/*
 * Packge : xml2json
 * Author : S. Hamblett <steve.hamblett@linux.com>
 * Date   : 16/02/2018
 * Copyright :  S.Hamblett
 */

import 'package:xml2json/xml2json.dart';
import '../test/xml2json_test_strings.dart';

void main() {
  // Create a client transformer
  final Xml2Json myTransformer = Xml2Json();

  // Parse a simple XML string
  myTransformer.parse(goodXmlString);
  print('XML string');
  print(goodXmlString);
  print('');

  // Transform to JSON using Badgerfish
  String json = myTransformer.toBadgerfish();
  print('Badgerfish');
  print('');
  print(json);
  print('');

  // Transform to JSON using GData
  json = myTransformer.toGData();
  print('GData');
  print('');
  print(json);
  print('');

  // Transform to JSON using Parker
  json = myTransformer.toParker();
  print('Parker');
  print('');
  print(json);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  xml2json: ^3.0.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:xml2json/xml2json.dart';
  
Version Uploaded Documentation Archive
3.0.3 Oct 3, 2018 Go to the documentation of xml2json 3.0.3 Download xml2json 3.0.3 archive
3.0.2 Oct 1, 2018 Go to the documentation of xml2json 3.0.2 Download xml2json 3.0.2 archive
3.0.1 Aug 16, 2018 Go to the documentation of xml2json 3.0.1 Download xml2json 3.0.1 archive
3.0.0 Aug 15, 2018 Go to the documentation of xml2json 3.0.0 Download xml2json 3.0.0 archive
2.0.14 Apr 24, 2018 Go to the documentation of xml2json 2.0.14 Download xml2json 2.0.14 archive
2.0.13 Apr 19, 2018 Go to the documentation of xml2json 2.0.13 Download xml2json 2.0.13 archive
2.0.12 Apr 6, 2018 Go to the documentation of xml2json 2.0.12 Download xml2json 2.0.12 archive
2.0.11 Feb 16, 2018 Go to the documentation of xml2json 2.0.11 Download xml2json 2.0.11 archive
2.0.10 Dec 11, 2017 Go to the documentation of xml2json 2.0.10 Download xml2json 2.0.10 archive
2.0.9 Jul 14, 2017 Go to the documentation of xml2json 2.0.9 Download xml2json 2.0.9 archive

All 20 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
83
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
92
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:xml2json/xml2json.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
xml >=3.0.0 <4.0.0 3.2.3
Transitive dependencies
collection 1.14.11
petitparser 2.0.2
Dev dependencies
build_runner ^0.10.0
build_test ^0.10.2
build_web_compilers ^0.4.0
coverage ^0.12.2
dart_style ^1.1.3
dartdoc ^0.20.3
test ^1.3.0