قراءة ملف من نوع XML والتخزين داخل Data Table
في البداية , نفتح مشروع جديد ونضع بداخله ملف XML كما في الصورة .
في البداية , نفتح مشروع جديد ونضع بداخله ملف XML كما في الصورة .
محتويات ملف XML
<!--?xml version="1.0" standalone="yes"?-->
<details>
<employee>
<firstname>muhammed</firstname>
<lastname>Yasser</lastname>
<location>Palestine</location>
</employee>
<employee>
<firstname>samer</firstname>
<lastname>Zaki </lastname>
<location>Palestine</location>
</employee>
<employee>
<firstname>Khalil</firstname>
<lastname>Khaled</lastname>
<location>Palestine</location>
</employee>
</details>
كود البرمجة لتخزين XML في Data Table , يتم تنفيذه بعد الضغط على button.
protected void Button1_Click(object sender, EventArgs e)
{
string filePath = Server.MapPath("~/Employee.xml");
//Employee Must match with the element name in
//your file
DataTable dt = new DataTable("employee");
//Add Columns in datatable
//Column names must match XML File nodes
dt.Columns.Add("firstname", typeof(System.String));
dt.Columns.Add("lastname", typeof(System.String));
dt.Columns.Add("location", typeof(System.String));
//Read XML File And Display Data in GridView
dt.ReadXml(filePath);
GridView1.DataSource = dt;
GridView1.DataBind();
}
يمكنك تحميل الكود بشكل كامل من هنا
--------------------------------------------------------------------------------------------------------------------------
في هذا الموضوع كيفية استتخدام مكتبة jQuery في تنسيق العنصر الخاص برفع الملفات , طبعا يجب أن يكون لديك في الصفحة مكتبة jquery كذلك الكود الخاص بالاضافة لعنصر التحكم المستخدم في رفع الملفات وسوف إستخدم "jQuery Custom File Input" , يمكنك تحميل الإضافة للعنصر File Uploader التي تعمل بإستخدام مكتبة Jquery اضغط هنا .
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> file upload control stylish using jQuery </title>
<link href="css/enhanced.css" rel="stylesheet" type="text/css" />
<script src="js/jQuery.fileinput.js" type="text/javascript"></script>
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="js/example.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#flUpload').customFileInput();
});
</script>
</head>
<body>
<form id="form1" runat="server">
<label for="file">Select File:</label>
<input type="file" name="file" id="flUpload" />
<input type="submit" name="upload" id="upload" value="Upload" />
</form>
</body>
</html>