• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Order of XML being preserved when writing to a file

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a script which strips off a couple nodes and then writes the script to a new file. The script works fine, but the attributes are not in the same order as in the original document. For example,

<Transaction DataType="N" ProgramNumber="08201" ProgramPhase="I" OCRMailCode="" OCRCellNumber="" OCROfferId="" OCRNameControl="083545995" OCRCheckDigit="" DateKeyed="20081007" BpData="" MediaCategory="EV" MediaCode="RN" UPCcode="" CCN="" RetailAccountNo="" PromoCode="">

displays

<Transaction OCRMailCode="" DataType="N" RetailAccountNo="" ProgramNumber="08201" MediaCode="RN" UPCcode="" CCN="" OCRCheckDigit="" MediaCategory="EV" OCROfferId="" BpData="" DateKeyed="20081007" ProgramPhase="I" PromoCode="" OCRCellNumber="" OCRNameControl="083545995">



I am using the XMLParser and printing doing the following.

new XmlNodePrinter(pw).print(ASD)


Does anyone know how one can preserve the order of attributes with the script?



 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't matter, because the XML recommendation specifically says that the order of attributes is not meaningful.
 
Bill Lee
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Appreciate the quick reply. Yes, the script works, but a lazy tester is asking if the attributes can maintain the existing order.
reply
    Bookmark Topic Watch Topic
  • New Topic