Parsing of XML files with namespaces

Source: Internet
Author: User

The XML format is as follows:

 

 
<?XML Version= "1.0" Encoding= "UTF-8"?>
 
<Soap: Envelope Xmlns: xsi= "Http://www.w3.org/2001/XMLSchema-instance" Xmlns: XSD= "Http://www.w3.org/2001/XMLSchema" Xmlns: Soap= "Http://schemas.xmlsoap.org/soap/envelope">
 
<Soap: Body>
 
<Get_job>
<Record>
 
<Title>
 
Internal recruitment of technical talent specialists in the Technical Development Department of the Group Company
 
</Title>
 
<End_date>
 
2012-08-16
 
</End_date>
 
<Job_url>
Http: // 10.33.1.39/HRMS/cimc_hr_trm_job_internal_readonly.service? Job_internal_id = 391
 
</Job_url>
 
</Record>
 
<Record>
 
<Title>
 
Internal recruitment of technical talent specialists in the Technical Development Department of the Group Company
 
</Title>
 
<End_date>
2012-08-13
 
</End_date>
 
<Job_url>
 
Http: // 10.33.1.39/HRMS/cimc_hr_trm_job_internal_readonly.service? Job_internal_id = 412
 
</Job_url>
 
</Record>
 
<Record>
 
<Title>
Internal recruitment of deputy general manager of production of Dalian CHONGHUA Leadership Team
 
</Title>
 
<End_date>
 
2012-08-24
 
</End_date>
 
<Job_url>
 
Http: // 10.33.1.39/HRMS/cimc_hr_trm_job_internal_readonly.service? Job_internal_id = 472
 
</Job_url>
</Record>
 
<Record>
 
<Title>
 
Assistant internal manager of screw Department of anruike pig Pressure Screw Department
 
</Title>
 
<End_date>
 
2012-08-31
 
</End_date>
<Job_url>
 
Http: // 10.33.1.39/HRMS/cimc_hr_trm_job_internal_readonly.service? Job_internal_id = 473
 
</Job_url>
 
</Record>
 
<Record>
 
<Title>
 
Internal recruitment of audit director of Group Company
 
</Title>
<End_date>
 
2012-08-16
 
</End_date>
 
<Job_url>
 
Http: // 10.33.1.39/HRMS/cimc_hr_trm_job_internal_readonly.service? Job_internal_id = 491
 
</Job_url>
 
</Record>
 
<Record>
<Title>
 
Internal recruitment of technical talent specialists in the Technical Development Department of the Group Company
 
</Title>
 
<End_date>
 
2012-08-15
 
</End_date>
 
<Job_url>
 
Http: // 10.33.1.39/HRMS/cimc_hr_trm_job_internal_readonly.service? Job_internal_id = 436
</Job_url>
 
</Record>
 
<Record>
 
<Title>
 
Internal recruitment of intern in the Strategic Research Office of the Group Company
 
</Title>
 
<End_date>
 
2012-08-22
</End_date>
 
<Job_url>
 
Http: // 10.33.1.39/HRMS/cimc_hr_trm_job_internal_readonly.service? Job_internal_id = 448
 
</Job_url>
 
</Record>
 
</Get_job>
 
</Soap: Body>
</Soap: Envelope>

The XML parsing method is as follows:

 

Xmldocument Doc =NewXmldocument ();

Doc. Load (@ "C: \ wicresoft \ webapplication1 \ consoleapplication2 \ test. xml");
 
// Set the namespace
 
Xmlnamespacemanager xmlnsmanager =NewXmlnamespacemanager (Doc. nametable );
 
Xmlnsmanager. addnamespace ("Soap",Http://schemas.xmlsoap.org/soap/envelope");
 
Xmlnodelist nodelist = Doc. selectnodes ("/Soap: envelope/soap: body/get_job/record", Xmlnsmanager );

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.