Unsolved XMLStreamWriter is writing the xml version and encoding type
-
Im writing an XML using streamwriter by default the below line is getting added at the begining How to remove this?
<?xml version="1.0" encoding="UTF-8"?> -
@Sriu1 are you sure you don't want such first line? Per XML specification is called document type declaration and "must appear before the first element in the document"
-
Hi,
@Pablo-J-Rogina Yes I want to get rid of them.Its getting written everytime I write new XML.And this version line is not being parsed.So I want to get rid of this line -
@Sriu1 Does this line cause any problems? If not why bother?
-
@jsulm Yes it is causing problems.Please suggest how to remove it.
-
@Sriu1 May I ask what problem it causes? As mentioned by @Pablo-J-Rogina this line is part of XML standard.
If you still want to remove it then you can do it manually: first write the file then read it and write manually skipping the first line. -
Im trying to run an old application using my XML.The application is working only if I remove XML declaration.So I want to get rid of it every time I write XML
-
I haven't tested it but wouldn't just not calling writeStartDocument achieve what you want ?