How may I modify a XML file without any change like attributes ordering, tag expansion and encoding? (My preference is DOM API)
You could try VTD-XML.
Since this library builds an index while keeping the file content as-is, its manipulation API will allow to "patch" your file while keeping the rest intact.
Using the VTD-XML API, you will be able to navigate your XML like a DOM tree (even using XPath) and do some modifications (insert elements, insert attributes, etc.)