我正在使用通過互聯網傳輸XML文檔的第三方DLL。爲什麼「根級數據無效,第1行,第1位」。對於XML文檔?
爲什麼DLL會拋出以下異常?在根級
數據是無效的。行1,位置1(見下文的 充分異常文本。)
下面是XML文檔的前幾行:
<?xml version="1.0" encoding="utf-8"?> <REQUEST> <HEADER>
<REQUESTID>8a5f6d56-d56d-4b7b-b7bf-afcf89cd970d</REQUESTID>
<MESSAGETYPE>101</MESSAGETYPE>
<MESSAGEVERSION>3.0.2</MESSAGEVERSION>
例外:
System.ApplicationException was caught
Message=Unexpected exception.
Source=FooSDK
StackTrace:
at FooSDK.RequestProcessor.Send(String SocketServerAddress, Int32 port)
at Foo.ExecuteRequest(Int32 messageID, IPayload payload, Provider prov)
at Foo.SendOrder(Int32 OrderNo)
InnerException: System.Xml.XmlException
LineNumber=1
LinePosition=1
Message=Data at the root level is invalid. Line 1, position 1.
Source=System.Xml
SourceUri=""
StackTrace:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at XYZ.RequestProcessor.GetObjectFromXML(String xmlResult)
at XYZ.RequestProcessor.Send(String SocketServerAddress, Int32 port)
InnerException:
如何將XML文件在互聯網上傳播的? HTTP?如果是,請檢查a)文件是否有BOM,以及b)HTTP標頭是否也指定了非UTF8字符集。 –