码迷,mamicode.com
首页 > 其他好文 > 详细

处理xml

时间:2014-09-12 01:11:02      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:io   ar   文件   sp   cti   on   c   ad   new   

using System.Xml;

using System;

using System.Text;

using System.Net;

using System.Collections;

using System.Collections.Generic;

 

 

public class xml

{

    public static string read( string path,string val1,string val2)// str1 文件位置  str2 父节点 str3 子节点

    {

        XmlDocument xml =new XmlDocument();

        xml.Load(path);

        XmlNode root=xml.SelectSingleNode(val1);

        string val=(root.SelectSingleNode(val2)).InnerText;

        return val;

        //返回子节点属性

    }

    

}

 

 

demo:

     var path=Server.MapPath("~/App_Data");

     path=path+"/ts.xml"; 

     string user=xml.read(path,"/xml","CreateTime");  

     @user

 

处理xml

标签:io   ar   文件   sp   cti   on   c   ad   new   

原文地址:http://www.cnblogs.com/lsz3034/p/3967549.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!