0
我收到錯誤這樣,當在文檔錯誤的頂層無效。 XML頁面無法顯示使用樣式表 無法查看XML輸入。請更正錯誤,然後點擊刷新按鈕,或稍後再試。 在按鈕點擊我寫這個。讀取XML文件
String strUrl = "https://secure.dev.gateway.gov.uk/submission";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strUrl);
req.ContentType = "text/xml";
req.Method = "POST";
req.Accept = "text/xml";
req.PreAuthenticate = true;
req.Credentials = new NetworkCredential("189", "");
req.UseDefaultCredentials = true;
System.IO.Stream stream = req.GetRequestStream();
string strXML = GetXmlString("C:\\Documents and Settings\\com\\My Documents\\Downloads\\18march\\VatDecRequest_ValidSample v1.0.xml");
byte[] arrBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(strXML);
stream.Write(arrBytes, 0, arrBytes.Length);
stream.Close();
WebResponse resp = req.GetResponse();
Stream respStream = resp.GetResponseStream();
StreamReader rdr = new StreamReader(respStream, System.Text.Encoding.ASCII);
Response.ContentType = "text/xml";
string strResponse = rdr.ReadToEnd();
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(strResponse);
xmldoc.Save("C:\\test9.xml");
我認爲錯誤是在XML文件或樣式表。你能否將它們包含在你的問題中(以防它們太大)? – 2011-04-06 10:47:15
您正在讀取和寫入ASCII - 你看,這始終是真的嗎?嘗試使用UTF-8編碼,它涵蓋了ASCII碼,如果出現則可以處理unicode。 (管線1返回的Unicode鏈接據我可以看到) – 2011-04-06 10:52:58