0
我試圖解析以下XML字符串:XmlReader無法用<qn:xxxxx>格式解析XML?
<qn:QueryNotification xmlns:qn="http://schemas.microsoft.com/SQL/Notifications/QueryNotification" id="307" type="change" source="data" info="insert" database_id="6" sid="0x010500000000000515000000AEA63BDE2DE94B9FF38541A8CD1A0000">
<qn:Message>Custom</qn:Message>
</qn:QueryNotification>
我以下列方式使用一個XmlReader:
using (XmlReader xmlReader = XmlReader.Create(new StringReader(z)))
{
xmlReader.Read();
}
當執行閱讀(),我得到以下異常:
XmlException:根級別的數據無效。第1行,第40位。
我不認爲它喜歡每個標籤之前的qn:。我如何設置XmlReader來解析這個文檔?
「z」的值究竟是什麼?它表示錯誤在'位置40',但是在問題中發佈的xml中有40個字符位於命名空間URI的中間。如果我用'var z =「
Random832
嗯...我解析z從Unicode字符串像這樣:string z = Encoding.Unicode.GetString(binaryString);我不知道是否有隱藏的無效字符... – lehn0058
什麼是binaryString?你能打印z的值嗎? – Random832