java读取xml文件操作

<?xml version="1.0" encoding="GB2312" standalone="yes"?>
<Msg Version="4" MsgID="1118732851" Type="TVMonUp" DateTime="2005-06-14 15:07:31" SrcCode="320200N01" DstCode="997777X10" ReplyID="66" >
<Return Type="StreamSimpleQuery" Value="0" Desc="?" >
</Return>
<Stream>
<MediaStream Index="0" url=" HTTP://10.40.30.2/playlist/42_0_42AE8233.asx" />
</Stream>
</Msg>


default.aspx.cs代码:


private void Page_Load(object sender, System.EventArgs e)
{
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@ 网站开发:lawdoor
//@@ 页面设计:lawdoor
//@@ Msn 联系:tacit@hotmail.com
//@@ QQ 联系:5985880
//@@ 网 站: http://www.cnsdn.com.cn
//@@ 电子邮件:lawdoor@126.com
//@@ 版权所有:中软网[龙脉科技]
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//从系统中取system.xml信息
XmlDocument United = new XmlDocument();
United.Load("C://WINNT//Config//system.xml");
string Xpath="/Msg/Stream/paths";
//获得url
XmlNode MStreams =United.SelectSingleNode(Xpath);
string xmlpath=MStreams .Attributes["xmlpath"].InnerText;

DateTime d=DateTime.Now;
string FilePath=""+xmlpath+""+d.ToString("yyyyMMddHHmmss")+".xml";
Request.SaveAs(FilePath,false);
//创建document
XmlDocument Unite = new XmlDocument();
Unite.Load(FilePath);
//定义节点路径
string Xpath1="/Msg/Stream/MediaStream";
string Xpath2="/Msg";
//获得url
XmlNode MStream =Unite.SelectSingleNode(Xpath1);
string url=MStream .Attributes["url"].InnerText;
//获得ReplyID
XmlNode ReplyID =Unite.SelectSingleNode(Xpath2);
string ID=ReplyID .Attributes["ReplyID"].InnerText;

//连接oracle数据库
string connstring="data source=searches;user id=searches;password=1234";
//实例化OracleConnection对象
oracleConnection myConnection = new oracleConnection(connstring);
string sqlStr = "Ins*rt Into down_asx (task_id,asxurl,xmlname,adtime) Values ('"+ID+"','"+url+"','"+FilePath+"','"+d+"')";
oracleCommand myCommand = new oracleCommand(sqlStr, myConnection);
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值