Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 909873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:57:12+00:00 2026-05-15T16:57:12+00:00

When writing in java the following: Element fieldEl = targetDocument.createElement(field); fieldEl.setAttribute(Wine,Marlo); fieldEl.setAttribute(Beer,Corona); The order

  • 0

When writing in java the following:

Element fieldEl = targetDocument.createElement("field");
fieldEl.setAttribute("Wine","Marlo");
fieldEl.setAttribute("Beer","Corona");

The order of adding the attributes are not kept in the result XML file.
How can I control the order of the attribute inside XML Element (so it will be easy for human being to read…) ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:57:12+00:00Added an answer on May 15, 2026 at 4:57 pm

    There is no defined order for attribute nodes according to the DOM standard:

    Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes.

    (emphasis added) and neither in the XML standard:

    Note that the order of attribute specifications in a start-tag or empty-element tag is not significant.

    I don’t think, that many DOM implementations support ordering of attributes at all. You’d have to write your own serialization mechanism in order to achieve ordering (no pun intended).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been writing Java swing GUI code for several years but the following syntax
I am interested in writing a Java program which does the following. Attach to
I'm writing a Java webservice with CXF. I have the following problem: A client
I have been writing java for a while, and today I encountered the following
I am facing the following problem: I am writing a java-application in Eclipse. Inside
I have the following. A Java process writing logs to the stdout A shell
Consider the following two ways of writing a loop in Java to see if
In the following statement: java.lang.Object.wait(Object.java:???)[Native Method] - waiting on <0x6ab0eb48> (a coldfusion.runtime.RWLock) coldfusion.runtime.RWLock.waitForLock(RWLock.java:154) What
I've been writing Java for the last couple of years , and now I've
Sometimes while writing Java in Eclipse, I write code that generates warnings. A common

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.