-1
我想從xsd生成xml,這個xml我想包含來自xsd的指定屬性。有任何想法嗎?使用ado.net從Xsd生成Xml
string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
string SaveLocation = Server.MapPath("Data") + "\\" + fn;
try
{
File1.PostedFile.SaveAs(SaveLocation);
Response.Write("The file has been uploaded.");
}
catch (Exception ex)
{
Response.Write("Error: " + ex.Message);
//Note: Exception.Message returns a detailed message that describes the current exception.
//For security reasons, we do not recommend that you return Exception.Message to end users in
//production environments. It would be better to put a generic error message.
}
try
{
XmlTextReader reader = new XmlTextReader(SaveLocation);
//XmlSchema myschema = XmlSchema.Read(reader, ValidationCallback);
while (reader.Read())
{
// LiteralURL.Text += reader.ReadString();
}
// Response.Write("\t"+myschema.Items);
XDocument doc = XDocument.Load(SaveLocation);
var ListNode = new List<XNode>();
if (doc != null)
{
Response.Write("nu este null");
}
else
{
Response.Write("Null !");
}
int i = 0;
string str = "";
foreach (XNode nodes in doc.Elements())
{
str = "node1: " + nodes.ToString();
ListNode[i] = nodes;
i++;
}
for(int j = 0; j < i; i++)
{
Response.Write("FirstNode:"+ ListNode[j]);
}
//Response.Write("FirstNode:");
Response.Write(str);
}
catch (Exception ex)
{
}
}
else
{
Response.Write("Please select a file to upload.");
}
這是不好的內容。無法讀取,可能太寬泛。請閱讀以下內容:https://stackoverflow.com/help/asking –