Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27341

XML without BOM with CRLF

$
0
0
Hello everybody.
I need to save my XML file in the UTF-8 format, but without BOM and with CRLF.
I have following procedure:

Dim doc As XmlDocument = New XmlDocument()
Dim docNode As XmlNode = doc.CreateXmlDeclaration("1.0", "UTF-8", Nothing)
doc.AppendChild(docNode)

Dim XKodFormularza As XmlElement = doc.CreateElement("Field1")
XKodFormularza.SetAttribute("Field2", "abc")
XKodFormularza.SetAttribute("Field3", "def")
XKodFormularza.InnerText = "any string"
Dim XWariantFormularza As XmlElement = doc.CreateElement("Field4") : XWariantFormularza.InnerText = "0"
Dim XNaglowek As XmlElement = doc.CreateElement("Header")

XNaglowek.AppendChild(XKodFormularza) : XNaglowek.AppendChild(XWariantFormularza)

Dim jpk As XmlElement = doc.CreateElement("Title")
jpk.SetAttribute("xmlns", "http://stackoverflow.com/questions/14839630/how-to-get-xml-with-header-xml-version-1-0")
jpk.AppendChild(XNaglowek)

doc.AppendChild(jpk)

Dim abc As New XmlTextWriter("product2.xml", New UTF8Encoding(False))
doc.Save(abc)


When I open the „product2.xml” file in Notepad++ I see only one long line in UTF-8, without BOM but without CRLF too.

How should I change my procedure to save XML file in the UTF-8 format, but without BOM and with CRLF ?

Jacek

Viewing all articles
Browse latest Browse all 27341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>