nsgmls parser giving error for UTF-8 encoded file "Character Data Not Allowed Here"
I am saving a file using the below function
Public Function SavetoFile(ByVal p_sFileName As String, ByVal p_sMessage As String, ByVal p_sEncoding As String) As Boolean
Dim oEncoding As System.Text.Encoding = System.Text.Encoding.GetEncoding(p_sEncoding)
Dim settings As System.Xml.XmlWriterSettings = New System.Xml.XmlWriterSettings()
settings.Indent = True
settings.OmitXmlDeclaration = True
settings.Encoding = oEncoding
Using writer As System.Xml.XmlWriter = System.Xml.XmlWriter.Create(p_sFileName, settings)
writer.WriteStartDocument()
writer.WriteRaw(p_sMessage)
writer.Close()
End Using
Return True
End Function
The same file when saved under different encoding
case 1: p_sEncoding=SHIFT-JIS -> using nsgmls.exe validating the file saved above with the dtd .I am not getting any error
case 2: p_sEncoding=UTF-8 -> using nsgmls.exe validating the file saved above with the dtd .I am getting an error "Character Data Not Allowed Here"
Earlier the code used to save the file is as below
Dim l_oReader As New MSXML2.SAXXMLReader60
Dim l_oWriter As New MSXML2.MXXMLWriter60
Dim l_oStream As New ADODB.Stream
l_oReader.contentHandler = l_oWriter
l_oWriter.byteOrderMark = False
l_oWriter.encoding = p_sEncoding
l_oWriter.omitXMLDeclaration = True
l_oWriter.indent = True
l_oStream.Open()
l_oStream.Charset = p_sEncoding
l_oWriter.output = l_oStream
l_oReader.parse(p_sMessage)
l_oWriter.flush()
l_oStream.SaveToFile(g_sTempProcessFolder & p_sFileName, ADODB.SaveOptionsEnum.adSaveCreateOverWrite)
using the above way to save the file using UTF-8 then I didn't get any errors while parsing using nsgmls.exe
What I have tried:
all the documnets i could find on the google regarding nsgmls.exe