您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

详细介绍XML的基本代码

2024/3/12 19:47:26发布23次查看
xml的基本代码详解
using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.xml; namespace day08_xml { class program { static void main(string[] args) { xmldocument doc = new xmldocument(); doc.load("computer.xml"); xmlnode root=doc.documentelement; foreach(xmlnode item in root.childnodes){ string id = item.attributes["id"].value; console.writeline(id); console.writeline("名称为"+item["name"].innertext); } //foreach(xmlnode item in root.childnodes){ //item是xml中的computer对象 // foreach(xmlnode child in item.childnodes){ // switch(child.name){ // case "name": // console.writeline("我的电脑是:"+child.innertext); // break; // } // } // } console.readline(); } } }
<?xml version="1.0" encoding="utf-8" ?> <computer> <computers id="110"> <name>联想</name> </computers> <computers id="120"> <name>苹果</name> </computers> </computer>
以上就是详细介绍xml的基本代码的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product