JavaScript accesses Web services to process XML result sets

Source: Internet
Author: User
Tags object web services xmlns access
javascript|services|web|xml| Access

The key code is as follows:

var xmlData = new ActiveXObject ("Msxml.domdocument"); Create a MSXML object
Xmldata.async = false//synchronous fetch data
Xmldata.load ("Web Service URL"); Passing parameters by get way, getting XML objects
Get XML object: Xmldata.xml
Get String:xmlData.text

XML data as shown below:

<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 </MinZu>
</GG_test>
<gg_test diffgr:id= "Gg_test1" msdata:roworder= "1" >
<ID>6</ID>
<XingMing>bbb</XingMing>
<XingBie> male </XingBie>
<MinZu> Han </MinZu>
</GG_test>
</Information >
</diffgr:diffgram>
To access a field that is xingming BBB, use the following JavaScript statement

XmlData.xml.getElementsByTagName ("Gg_test"). Item (1). ChildNodes (1). Text

The idea is to find the Gg_test table, find the record with index 1, and find the contents of the field indexed by 1.



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.