我正嘗試讀取由ASP腳本創建的動態xml,但不幸的是我無法讀取。看來我的C#代碼無法理解ASP腳本。從動態asp腳本讀取動態xml
我很樂意聽到一些建議。
你可以看到ASP腳本的位置:http://www.ad-net.co.il/test.asp
<%
Response.Buffer = True
Response.ContentType = "text/xml"
body = ""
body = body & "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<PROGRAM>"
body = body & "<EMAIL>[email protected]</EMAIL>"
body = body & "<USERNAME>[email protected]</USERNAME>"
body = body & "<PASSWORD>password</PASSWORD>"
body = body & "</PROGRAM>"
Response.Write(body)
%>
的C#代碼:
private static void LoadXmlFromServerToProgram()
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load("http://www.ad-net.co.il/test.asp");
EMAIL = xDoc.DocumentElement.SelectSingleNode("EMAIL").InnerText;
USERNAME = xDoc.DocumentElement.SelectSingleNode("USERNAME").InnerText;
PASSWORD = xDoc.DocumentElement.SelectSingleNode("PASSWORD").InnerText;
}
catch
{
MessageBox.Show("Can't Read From XML");
}
}
能否請您提供詳細信息, ...)。另外請考慮製作變量名稱camelCase,而不是ALL-UPPER-CASE。 – 2012-07-19 23:03:40
您的示例C#代碼在新的控制檯應用程序中完美工作。 (將3個變量聲明爲字符串)。您是否使用過Visual Studio調試器來遍歷代碼? http://imgur.com/m57JL – 2012-07-19 23:04:57
我已經聲明它是一個字符串,但仍然不會工作 – 2012-07-19 23:12:06