I'm attempting to teach myself XML integration into VB.Net
I've created some code that creates a XML document but I am having and issue with the encoding information being entered into the XML document.
When the document is created the first line looks like
instead of
like I'm expecting.
I'm not even sure if it is even very important but I'm curious why it is doing this.
Thanks a bunch,
Grant
I've created some code that creates a XML document but I am having and issue with the encoding information being entered into the XML document.
VB.NET:
Imports System
Imports System.Xml
Public Class Form1
Private Sub btnCreateDocument_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateDocument.Click
' Create the XmlDocument.
Dim docXML As XmlDocument = New XmlDocument()
docXML.LoadXml( _
"<?xml version=""1.0"" encoding=""UTF-8""?>" & _
"<?xml-stylesheet href=""style.css"" type=""text/css""?>" & _
"<SigBlocks>" & _
"<SigBlock BlockName=""Dan - Work"">" & _
"<FName>Dan</FName>" & _
"<FNameChecked>False</FNameChecked>" & _
"<LName>Mabbutt</LName>" & _
"<LNameChecked>False</LNameChecked>" & _
"<Address>About Visual Basic</Address>" & _
"<AddressChecked>True</AddressChecked>" & _
"<Phone>(555) 555-5555</Phone>" & _
"<PhoneChecked>False</PhoneChecked>" & _
"<SSN>123-45-6789</SSN>" & _
"<SSNChecked>False</SSNChecked>" & _
"<Email>visualbasic@about.com</Email>" & _
"<EmailChecked>True</EmailChecked>" & _
"</SigBlock>" & _
"<SigBlock BlockName=""Dan - Personal"">" & _
"<FName>Dan</FName>" & _
"<FNameChecked>True</FNameChecked>" & _
"<LName>Mabbutt</LName>" & _
"<LNameChecked>True</LNameChecked>" & _
"<Address>Home Sweet Home</Address>" & _
"<AddressChecked>False</AddressChecked>" & _
"<Phone>(123) 456-7890</Phone>" & _
"<PhoneChecked>True</PhoneChecked>" & _
"<SSN>123-45-6789</SSN>" & _
"<SSNChecked>False</SSNChecked>" & _
"<Email>me@MyOwnDomain.com</Email>" & _
"<EmailChecked>False</EmailChecked>" & _
"</SigBlock>" & _
"</SigBlocks>")
' Save the document to a file and auto-indent the output.
Dim writer As XmlTextWriter = New XmlTextWriter("e:\Name.xml", Nothing)
writer.Formatting = Formatting.Indented
docXML.Save(writer)
End Sub
End Class
When the document is created the first line looks like
VB.NET:
<?xml version="1.0"?>
VB.NET:
<?xml version="1.0" encoding="UTF-8"?>
I'm not even sure if it is even very important but I'm curious why it is doing this.
Thanks a bunch,
Grant