2012-07-03 62 views
4

我目前有一個將數據從VBA(Access)傳輸到C#(通過ASP.NET POST)的程序。我如何在每一端進行編碼/解碼?如何在VBA和C中對XML進行編碼/解碼#

這裏是我的XML閱讀C#:

StreamReader reader = new StreamReader(Request.InputStream); 
string xmlData = ""; 
XmlDocument xml = new XmlDocument(); 
xmlData = reader.ReadToEnd(); 
XmlElement rootXML; 
xml.LoadXml(xmlData); 
rootXML = xml.DocumentElement; 

這裏是C#我的XML寫:

Response.Clear(); 
Response.ContentType = "text/xml"; 
Response.Charset = "UTF-8"; 
Response.Write(XML_in_String); 
Response.End(); 

這裏是VBA

我的XML寫
connection.Open "POST", server & "www.webpage.com/" & postData, False 
connection.setRequestHeader "Accept", "application/xml" 
connection.setRequestHeader "Content-Type", "application/xml" 
connection.send "<?xml version=""1.0"" encoding=""UTF-8"" ?><data>" & outXMLstr & "</data>" 

這裏我在VBA中讀取的XML

Dim inXML As MSXML2.DOMDocument 
Set inXML = New DOMDocument 
inXML.loadXML (connection.responseText) 

具體來說,當我嘗試loadXML(xmlData)時,C#出現錯誤,因爲它無法解析&符號(&)。

+1

它,你要編碼符號來&使用Server.HtmlEncode&Server.HtmlDecode – HatSoft

+1

哪裏符號它有問題 - 在你的XML中?你能展示那部分XML嗎? –

回答

相關問題