Javascript accesses web services to process XML result sets

Source: Internet
Author: User

KeyCodeAs follows:

VaR Xmldata =   New Activexobject ( " MSXML. domdocument " ); // Create an MSXML object
Xmldata. async =   False   // Synchronously retrieve data
Xmldata. Load ( " Web Service URL " ); // PASS Parameters in get mode to get XML objects
Get XML Object: xmldata. xml
Obtain string: xmldata. Text

XML data is shown as follows:

< Diffgr: DiffGram Xmlns: msdata = "Urn: Schemas-Microsoft-com: XML-msdata" Xmlns: diffgr = "Urn: Schemas-Microsoft-com: xml-diffgram-v1" >
< Information xmlns = "" >
< Gg_test Diffgr: ID = "Gg_test1" Msdata: roworder = "0" >
< ID > 5 </ ID >
< Xingming > Aaa </ Xingming >
< Xingbie > Male </ Xingbie >
< Minzu > Han Nationality </ Minzu >
</ Gg_test >
< Gg_test Diffgr: ID = "Gg_test1" Msdata: roworder = "1" >
< ID > 6 </ ID >
< Xingming > Bbb </ Xingming >
< Xingbie > Male </ Xingbie >
< Minzu > Han Nationality </ Minzu >
</ Gg_test >
</ Information >
</ Diffgr: DiffGram >

To access the Xingming BBB field, use the following JavaScript statement

Xmldata. xml. getelementsbytagname ("gg_test"). Item (1). childnodes (1). Text

The general meaning is to first find the gg_test table, then find the record with the index of 1, and then find the content of the field with the index of 1,

I hope you will have more exchanges.

Related Article

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.