How does Ajax obtain XML document data hierarchically?

Source: Internet
Author: User

The following is a layer-4 directory tree that is expanded step by step. The data in the directory tree is obtained from a very large XML file with the same structure. When the page is opened, obtain the data of the first two layers. When you click a list item, you can obtain the data of the next two layers (lower and lower layers because the data is obtained at the beginning of the next layer) of the list item in real time.
----------------------

From http://bbs.blueidea.com/viewthread.php? Tid = 2676250

======================================

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Style type = "text/CSS">
Ul {
Font-size: 12px;
}
Li {
Cursor: pointer;
}
</Style>
<Title> category display </title>
</Head>
<Body>
<Div>
<Div>
<Div>
<Ul id = "layerunspsc1">
<Li> layer-3 Node
<Ul>
<Li> layer-3 Node
<Ul>
<Li> layer-3 Node
<Ul>
<Li> layer-3 node </LI>
<Li> layer-3 node </LI>
</Ul>
</LI>
<Li> layer-3 Node
<Ul>
<Li> layer-3 node </LI>
<Li> layer-3 node </LI>
</Ul>
</LI>
</Ul>
</LI>
<Li> layer-3 Node
<Ul>
<Li> layer-3 Node
<Ul>
<Li> layer-3 node </LI>
<Li> layer-3 node </LI>
</Ul>
</LI>
<Li> layer-3 Node
<Ul>
<Li> layer-3 node </LI>
<Li> layer-3 node </LI>
</Ul>
</LI>
</Ul>
</LI>
</Ul>
</LI>
<Li> layer-3 Node
<Ul>
<Li> layer-3 Node
<Ul>
<Li> layer-3 Node
<Ul>
<Li> layer-3 node </LI>
<Li> layer-3 node </LI>
</Ul>
</LI>
<Li> layer-3 Node
<Ul>
<Li> layer-3 node </LI>
<Li> layer-3 node </LI>
</Ul>
</LI>
</Ul>
</LI>
<Li> layer-3 Node
<Ul>
<Li> layer-3 Node
<Ul>
<Li> layer-3 node </LI>
<Li> layer-3 node </LI>
</Ul>
</LI>
<Li> layer-3 Node
<Ul>
<Li> layer-3 node </LI>
<Li> layer-3 node </LI>
</Ul>
</LI>
</Ul>
</LI>
</Ul>
</LI>
</Ul>
</Div>
</Div>
</Div>
<SCRIPT type = "text/JavaScript">
VaR layerunspsc1 = Document. getelementbyid ("layerunspsc1 ");
VaR layerunspsc1_li = layerunspsc1.getelementsbytagname ("Li ");
For (VAR I = 0; I <layerunspsc1_li.length; I ++ ){
For (var j = 0; j <layerunspsc1_li [I]. childnodes. length; j ++ ){
VaR ul = layerunspsc1_li [I]. childnodes [J];
If (UL. nodename = "Ul "){
Ul. style. Display = "NONE ";
}
}
}
Layerunspsc1.onclick = function (NAV ){
VaR li = (document. All )? Event. srcelement: nav.tar get;
If (Li. nodename = "Li "){
For (VAR a = 0; A <li. childnodes. length; A ++ ){
VaR ul = Li. childnodes [a];
If (UL. nodename = "Ul "){
Ul. style. Display = (UL. style. Display = "NONE ")? "": "NONE ";
}
}
}
}
</SCRIPT>
</Body>
</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.