java - Read/write XML file preserving original attribute order -
i using javax.xml.parsers.documentbuilder
parse existing xml file , instance of org.w3c.dom.document
.
after manipulations on instance, need write file. therefore how can write org.w3c.dom.document
object xml file using xmlstreamwriter
?
ps: asking this, because think need use xmlstreamwriter
in order write xml file without losing attribute orders. attribute orders important because in version tree, because of attribute order changes, don't want see xml file changed.
attribute order insignificant per xml recommendation:
note order of attribute specifications in start-tag or empty-element tag not significant.
therefore, xmlstreamwriter provides no way constrain attribute ordering.
in general, xml recommendations consider attribute ordering insignificant, see section on attribute processing in xml normalization recommendation or canonical xml recommendation if application has need attribute ordering.
Comments
Post a Comment