私はXmlDocument(ファイルに保存されている)に持っているオブジェクトをシリアル化しようとしています。問題は、(UltraEditを使用して)ファイルを16進表現で表示すると、実際のxmlの前に配置されているように見えることです。これらの文字は、問題を引き起こしている別のプログラムによって読み取られています。xmlの先頭に予期しない先頭の16進数文字
最初の行は、この(
をリードする通知を)含まれています
<?xml version="1.0" encoding="utf-8"?>
私はなぜ私はそれらの文字を取得していますかわかりません。
文書作成するコード:
' At this point, I have an object called newObj that has mostly string/integer fields.
' It is non-null as populated with the correct data.
xd = New XmlDocument
Dim xs As XmlSerializer = New XmlSerializer(GetType(MyObj))
Dim result As String = String.Empty
Using ms As MemoryStream = New MemoryStream()
xs.Serialize(ms, newObj)
ms.Position = 0
result = New StreamReader(ms).ReadToEnd()
End Using
xd.LoadXml(result)
をそして、私はここにファイルを作成します。
Using xw As XmlTextWriter = New XmlTextWriter(myFile, New UTF8Encoding(True))
xw.Formatting = Formatting.Indented
xw.Indentation = 1
xw.IndentChar = " "
xd.Save(xw)
End Using
フラグ@Defaultをありがとう!それは、それが呼び出されたという考えはありませんが、それはトリックでした! –
np、あなたが以前にあなたの正確な問題を抱えていたため、私が知っている理由は次のとおりです。 – Default