0

I am using xmlbuilder2 to searilize JSON Object

 const newXml = convert(doc, {
      format: 'xml',
      headless: true,
      prettyPrint: true,
      newline: ' ',
    });

I want to pretty print XML with whitespace so that each tag appears on a newline like below:

 <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">

but XMLSearilizer prints it like below in line :

 <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme">

Is it possible to generate each property tag in newline ?

Thanks

Bhupendra
  • 1,196
  • 16
  • 39
  • The Saxon serializer will output attributes in this format, if that's any use to you. If you're that concerned about the final layout, you may want to use different tools for the conversion and the serialization. But no serializer is going to give you exactly what you want every time. – Michael Kay Feb 24 '23 at 14:23

0 Answers0