File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ var getXML2 = ( url , callback ) => {
2+
3+ let xhr = new XMLHttpRequest ( ) ;
4+ xhr . open ( 'GET' , url , true ) ;
5+ xhr . responseType = 'xml' ;
6+
7+ xhr . onload = ( ) => {
8+
9+ let status = xhr . status ;
10+
11+ if ( status == 200 ) {
12+ callback ( null , xhr . responseXML ) ;
13+ } else {
14+ callback ( status ) ;
15+ }
16+ } ;
17+
18+ xhr . send ( ) ;
19+ } ;
20+
21+ getXML2 ( 'http://webcode.me/users.xml' , ( err , xml ) => {
22+
23+ if ( err != null ) {
24+ console . error ( err ) ;
25+ } else {
26+
27+ let users = xml . getElementsByTagName ( "user" ) ;
28+
29+ for ( let i = 0 ; i < users . length ; i ++ ) {
30+
31+ let value = '' ;
32+
33+ for ( let j = 0 ; j < users [ i ] . children . length ; j ++ ) {
34+ value += " " + users [ i ] . children [ j ] . innerHTML ;
35+ }
36+
37+ let node = document . createElement ( "li" ) ;
38+ let textnode = document . createTextNode ( value ) ;
39+
40+ node . appendChild ( textnode ) ;
41+ document . getElementById ( "output" ) . appendChild ( node ) ;
42+ }
43+ }
44+ } ) ;
You can’t perform that action at this time.
0 commit comments