How to indent XML properly using XMLSerializer?

前端 未结 4 1313
野性不改
野性不改 2021-02-07 14:39

I\'m having a hard time trying to indent XML files using XMLSerializer.

I\'ve tried

serializer.setFeature(\"http://xmlpull.org/v1/doc/featur         


        
4条回答
  •  你的背包
    2021-02-07 14:44

    Have you tried using these two properties "in combination" on Serializer?

    // indentation as 3 spaces
    serializer.setProperty(
       "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "   ");
    // also set the line separator
    serializer.setProperty(
       "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n");
    

提交回复
热议问题