91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 56KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-14
  • 語言: C#
  • 標簽: C#讀xml??

資源簡介

C#winform讀xml源碼(適合新手)http://www.cnblogs.com/a1656344531/archive/2012/11/28/2792863.html跟著這個教程做的,網址中有不少小錯誤會讓新手比較抓狂,所以附上源碼給各位新手,希望你能幫到大家。

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?System.xml;

namespace?使用xmlDocument
{
????public?partial?class?Form1?:?Form
????{
????????List?bookModelList?=?new?List();
????????public?class?BookModel
????????{
????????????public?BookModel()
????????????{?}
????????????///?
????????????///?所對應的課程類型
????????????///?

????????????private?string?bookType;
????????????public?string?BookType
????????????{
????????????????get?{?return?bookType;?}
????????????????set?{?bookType?=?value;?}
????????????}
????????????///?
????????????///?書所對應的ISBN號
????????????///?

????????????private?string?bookISBN;

????????????public?string?BookISBN
????????????{
????????????????get?{?return?bookISBN;?}
????????????????set?{?bookISBN?=?value;?}
????????????}
????????????///?
????????????///?作者
????????????///?

????????????private?string?bookAuthor;


????????????public?string?BookAuthor
????????????{
????????????????get?{?return?bookAuthor;?}
????????????????set?{?bookAuthor?=?value;?}
????????????}

????????????///?
????????????///書名
????????????///?

????????????private?string?bookName;
????????????public?string?BookName?{
????????????????get?{?return?bookName;?}
????????????????set?{?bookName?=?value;?}
????????????}

????????????///?
????????????///?價格
????????????///?

????????????private?double?bookPrice;
????????????

????????????public?double?BookPrice?{
????????????????get?{?return?bookPrice;?}
????????????????set?{?bookPrice?=?value;?}
????????????}?

????????}
????????public?Form1()
????????{
????????????InitializeComponent();
????????}

????????private?void?button1_Click(object?sender?EventArgs?e)
????????{???
????????????//首先,實例化對話框類實例
????????????OpenFileDialog?openDialog?=?new?OpenFileDialog();
????????????if(DialogResult.OK?==?openDialog.ShowDialog())
????????????{
????????????????string?path?=?openDialog.FileName;
????????????????xmlDocument?doc?=?new?xmlDocument();
????????????????xmlReaderSettings?settings?=?new?xmlReaderSettings();
????????????????settings.IgnoreComments?=?true;//忽略文檔里面的注釋
????????????????xmlReader?reader?=?xmlReader.Create(pathsettings);
????????????????doc.Load(reader);
????????????????//得到根節點
????????????????xmlNode?xn?=?doc.SelectSingleNode(“bookstore“);

????????????????//得到根節點的所有子節點
????????????????xmlNodeList?xnl?=?xn.ChildNodes;

????????????????foreach(xmlNode?xn1?in?xnl){
????????????????????BookModel?bookModel?=?new?BookModel();
????????????????????//將節點轉換為元素,便于得到節點的屬性值
????????????????????xmlElement?xe?=(xmlElement)xn1;
????????????????????//得到Type和ISBN兩個屬性的屬性值
????????????????????bookModel.BookISBN?=?xe.GetAttribute(“ISBN“).ToString();

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-07-23?08:31??使用xmlDocument\
?????文件?????????187??2016-07-22?17:02??使用xmlDocument\App.config
?????文件????????1138??2016-07-23?08:34??使用xmlDocument\Book.xml
?????文件????????2885??2016-07-23?08:59??使用xmlDocument\Form1.Designer.cs
?????文件????????3810??2016-07-23?09:07??使用xmlDocument\Form1.cs
?????文件????????5817??2016-07-23?08:59??使用xmlDocument\Form1.resx
?????文件?????????529??2016-07-22?17:02??使用xmlDocument\Program.cs
?????目錄???????????0??2016-07-23?08:51??使用xmlDocument\Properties\
?????文件????????1354??2016-07-22?17:02??使用xmlDocument\Properties\AssemblyInfo.cs
?????目錄???????????0??2016-07-23?08:51??使用xmlDocument\Properties\DataSources\
?????文件?????????615??2016-07-23?08:51??使用xmlDocument\Properties\DataSources\Form1.BookModel.datasource
?????文件?????????595??2016-07-23?08:51??使用xmlDocument\Properties\DataSources\Form1.datasource
?????文件?????????599??2016-07-23?08:51??使用xmlDocument\Properties\DataSources\Program.datasource
?????文件?????????614??2016-07-23?08:51??使用xmlDocument\Properties\DataSources\使用xmlDocument.Properties.Resources.datasource
?????文件?????????612??2016-07-23?08:51??使用xmlDocument\Properties\DataSources\使用xmlDocument.Properties.Settings.datasource
?????文件????????2886??2016-07-22?17:02??使用xmlDocument\Properties\Resources.Designer.cs
?????文件????????5612??2016-07-22?17:02??使用xmlDocument\Properties\Resources.resx
?????文件????????1104??2016-07-22?17:02??使用xmlDocument\Properties\Settings.Designer.cs
?????文件?????????249??2016-07-22?17:02??使用xmlDocument\Properties\Settings.settings
?????目錄???????????0??2016-07-22?17:02??使用xmlDocument\bin\
?????目錄???????????0??2016-07-23?08:36??使用xmlDocument\bin\Debug\
?????文件???????10752??2016-07-23?09:07??使用xmlDocument\bin\Debug\使用xmlDocument.exe
?????文件?????????187??2016-07-22?17:02??使用xmlDocument\bin\Debug\使用xmlDocument.exe.config
?????文件???????30208??2016-07-23?09:07??使用xmlDocument\bin\Debug\使用xmlDocument.pdb
?????文件???????22984??2016-07-23?09:13??使用xmlDocument\bin\Debug\使用xmlDocument.vshost.exe
?????文件?????????187??2016-07-22?17:02??使用xmlDocument\bin\Debug\使用xmlDocument.vshost.exe.config
?????文件?????????490??2015-10-30?15:19??使用xmlDocument\bin\Debug\使用xmlDocument.vshost.exe.manifest
?????目錄???????????0??2016-07-22?17:02??使用xmlDocument\obj\
?????目錄???????????0??2016-07-23?09:07??使用xmlDocument\obj\Debug\
?????文件????????7563??2016-07-23?08:51??使用xmlDocument\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件????????7764??2016-07-23?08:51??使用xmlDocument\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
............此處省略12個文件信息

評論

共有 條評論

相關資源