How to access XML data using javascript _ javascript

Source: Internet
Author: User
Internet Explorer (IE) is now a standard software for instances that use javascript to access XML data. We can see that almost every machine running different versions of Windows (and many other operating systems) uses IE. Microsoft has used ActiveX controls to include IE functions in sophisticated XML processing technology.

In this article, we will describe how to use ActiveX functions in IE to access and parse XML documents, thus allowing Web surfers to manipulate them.

Surfing the internet
We start with A standard document, as shown in table. This document contains simple ordered data for browsing by web surfers. In addition to displaying the data, we also provide a simple user interface that allows web surfing to browse XML documents.

Table A: order. xml


9900234

  1234
  5.95
  100
  595.00
  Super Widget Clamp


  6234
  22.00
  10
  220.00
  Mighty Foobar Flange


  9982
  2.50
  1000
  2500.00
  Deluxe Doohickie


  3256
  389.00
  1
  389.00
  Muckalucket Bucket

1111
3704.00
07/07/2002
8876


We use a web form to access this XML document. This form displays the SKU, price, quantity, subtotal of each part, and descriptions of each option in the sequence. Our form also contains buttons for the forward and backward browsing options.

Web page Composition
An important part of a webpage is the form. We will use a table to display it on the screen in a readable manner. The following code snippet shows the HTML table:



Note that the table contains two buttons: getDataNext () and getDataPrev () to view the previous and next records, this is what we will discuss.

Script
In fact, the essence of our webpage is not the form, but the form control script. There are four parts in our script. First, we initialize the webpage by loading the XML document. The second part is to navigate to the next record. Step 3: navigate to the previous record. The fourth part is to extract a single value from the XML document. Table B shows all the content of our webpage.

Table B: jsxml.html


 

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.