renggli / dart-xml

Lightweight library for parsing, traversing, and transforming XML in Dart.
http://pub.dartlang.org/packages/xml
MIT License
223 stars 52 forks source link

How to add new line before each attribute? #169

Closed vunguyen7797 closed 1 year ago

vunguyen7797 commented 1 year ago

I am trying to obtain this format in the ouput:

<gpx version="1.1" creator="dart-gpx library"
    xmlns="http://www.topografix.com/GPX/1/1"
    xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v2"
    xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"
    xmlns:gpxacc="http://www.garmin.com/xmlschemas/AccelerationExtension/v1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v2 http://www.garmin.com/xmlschemas/TrackPointExtensionv2.xsd http://www.garmin.com/xmlschemas/AccelerationExtension/v1 http://www.garmin.com/xmlschemas/AccelerationExtensionv1.xsd"

/>

However, I still couldn't find out away to add a newline before adding each attribute. All the attributes of the elements seem always be on the same line. Is there anyway available to achieve this?

renggli commented 1 year ago

Use indentAttribute when pretty-printing, see toXmlString.