Java reads XML files

Source: Internet
Author: User
<? XML version = "1.0" encoding = "gb2312" standalone = "yes"?>
<MSG version = "4" msgid = "1118732851" type = "tvmonup" datetime = "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 code:

Private void page_load (Object sender, system. eventargs E)
{
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @ Website development: lawdoor
// @ Page design: lawdoor
// @ MSN contact: tacit@hotmail.com
/// @ Qq contact: 5985880
// @ Site: http://www.cnsdn.com.cn
// @ Email: lawdoor@126.com
// @ Copyright: chinanetcenter [longmai technology]
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Retrieve system. XML Information from the system
Xmldocument United = new xmldocument ();
United. Load ("C: // winnt // config // system. xml ");
String XPath = "/MSG/stream/paths ";
// Obtain the 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 );
// Create a document
Xmldocument unite = new xmldocument ();
Unite. Load (filepath );
// Define the Node path
String xpath1 = "/MSG/stream/mediastream ";
String xpath2 = "/MSG ";
// Obtain the URL
Xmlnode mstream = unite. selectsinglenode (xpath1 );
String url = mstream. attributes ["url"]. innertext;
// Obtain the replyid
Xmlnode replyid = unite. selectsinglenode (xpath2 );
String id = replyid. attributes ["replyid"]. innertext;

// Connect to the Oracle database
String connstring = "Data Source = searches; user id = searches; Password = 1234 ";
// Instantiate the oracleconnection object
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 ();
}
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.