Loading ...
Sorry, an error occurred while loading the content.
 

How can I print attributes in seperate lines using JDOM XMLOutputter

Expand Messages
  • huy_thuyha@yahoo.com
    The default XML output from JDOM XMLOutputter puts all attributes in one line:
    Message 1 of 1 , Jul 5, 2001
      The default XML output from JDOM XMLOutputter puts all attributes in
      one line:

      <MoveData start_time="5.5" end_time="5000.5" speed="30" altitude="5"
      initial_lat="10.142" initial_long="10.142" heading_lat="10.0"
      heading_long="10.0"></MoveData>

      I really want it print out as:

      <MoveData
      start_time="5.5"
      end_time="5000.5"
      speed="30"
      altitude="5"
      initial_lat="10.142"
      initial_long="10.142"
      heading_lat="10.0"
      heading_long="10.0">
      </MoveData>

      Using JDOM v0.6 beta.
      And writer code look like this:

      FileWriter
      writer = new FileWriter("aba.xml");
      XMLOutputter
      fmt = new XMLOutputter(" ", true);
      fmt.setLineSeparator(System.getProperty("line.separator"));
      fmt.setNewlines(true);
      fmt.setExpandEmptyElements(true);
      fmt.output(doc, writer);
      writer.close();

      Thanks!
    Your message has been successfully submitted and would be delivered to recipients shortly.