Diễn đàn    Các Projects Dotnetnuke (DNN)    Đọc file xml bỏ qua Namespace

Thành viênTrả lời
nguyetanh

Cửu âm bạch cốt trảo
22  bài
29-3-2018 10:45:26
XmlDocument doc = new XmlDocument();
XmlTextReader tr = new XmlTextReader(Server.MapPath("/1001-vt.xml"));
tr.Namespaces = false;
doc.Load(tr);

=====
Nếu đọc file XML theo dạng bình thường sẽ như sau :

XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("/1001-vt.xml"));

Khi đọc dạng này file xml sẽ có kết quả như sau :

<ArrayOfGD192021 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">
<GD192021>
<ID>0</ID>
<MA>N03.01.070</MA>
<TEN>BƠM TIÊM MPV 20 ML</TEN>
<TONG_LUOT>4</TONG_LUOT>
<DONGIA>2500</DONGIA>
<DON_VI_TINH>CÁI</DON_VI_TINH>
<QUYCACH>Hộp 50 chiếc x 16 hộp/kiện</QUYCACH>
</GD192021>
.....
</ArrayOfGD192021>

Dạng này không Transform được.
Xóa cái namespace quái quỷ này xmlns="http://tempuri.org/" thì lại transform bình thường
Xóa cái xmlns="http://tempuri.org/" trong code C# thì khó như lên trời, code đau tay.
 

Chủ đề gần đây :

Cùng loại :

Tên file Mô tả chi tiết Ngày
NWeb.zip (1) Module đơn giản Newsweb trên Dotnetnuke v10.x.x.x10/18/2025 8:08:11 AM
vspforum.zip (11) Ma nguon vspforum ngay xua4/18/2023 6:38:37 AM
pdfjs.rar (2) pdfjs 2017 : hiển thị tốt trên iphone 11, 12, 13 không lỗi, bản 2012 sẽ lỗi trên iphone6/21/2022 11:52:48 AM
pdfjs2.rar (2) Xem file pdf bằng viewer.hml cua pdfjs (thư viện chuẩn mozilla) 2012. https://mozilla.github.io/pdf.js/getting_started/#download có thể download bản prebuild tại đây6/21/2022 11:52:04 AM
runner.zip (0) using three.js, orbitcontrol to view an object move random on map. Di chuyển 1 đồ vật ngẫu nhiên trên bản đồ, sử dụng với demo nhân viên di chuyển trong văn phòng. Toàn js download về là chạy12/5/2019 5:55:14 PM
gmap.zip (1) google map + marker7/17/2019 2:25:05 PM
vinsmarthomeservice.zip (1) java post json to api, use AsyncTask, event listener7/9/2019 5:00:10 PM
fblogin.zip (0) Login facebook bang javascript SDK7/9/2019 9:16:37 AM
autocomplete-location.zip (2) autocomplete location geo from google place, html + js7/4/2019 4:37:55 PM
WebAPI.zip (8) api for android access db (v1.0.0)7/4/2019 9:14:17 AM