@@ -16,7 +16,9 @@ exports.parse = function(xmlData, options, validationOption) {
1616 }
1717 }
1818 options = buildOptions ( options , x2xmlnode . defaultOptions , x2xmlnode . props ) ;
19- return nodeToJson . convertToJson ( xmlToNodeobj . getTraversalObj ( xmlData , options ) , options ) ;
19+ const traversableObj = xmlToNodeobj . getTraversalObj ( xmlData , options )
20+ //print(traversableObj, " ");
21+ return nodeToJson . convertToJson ( traversableObj , options ) ;
2022} ;
2123exports . convertTonimn = require ( '../src/nimndata' ) . convert2nimn ;
2224exports . getTraversalObj = xmlToNodeobj . getTraversalObj ;
@@ -27,3 +29,39 @@ exports.j2xParser = require('./json2xml');
2729exports . parseToNimn = function ( xmlData , schema , options ) {
2830 return exports . convertTonimn ( exports . getTraversalObj ( xmlData , options ) , schema , options ) ;
2931} ;
32+
33+
34+ function print ( xmlNode , indentation ) {
35+ if ( xmlNode ) {
36+ console . log ( indentation + "{" )
37+ console . log ( indentation + " \"tagName\": \"" + xmlNode . tagname + "\", " ) ;
38+ if ( xmlNode . parent ) {
39+ console . log ( indentation + " \"parent\": \"" + xmlNode . parent . tagname + "\", " ) ;
40+ }
41+ console . log ( indentation + " \"val\": \"" + xmlNode . val + "\", " ) ;
42+ console . log ( indentation + " \"attrs\": " + JSON . stringify ( xmlNode . attrsMap , null , 4 ) + ", " ) ;
43+
44+ if ( xmlNode . child ) {
45+ console . log ( indentation + "\"child\": {" )
46+ const indentation2 = indentation + indentation ;
47+ Object . keys ( xmlNode . child ) . forEach ( key => {
48+ const node = xmlNode . child [ key ] ;
49+
50+ if ( Array . isArray ( node ) ) {
51+ console . log ( indentation + "\"" + key + "\" :[" )
52+ node . forEach ( ( item , index ) => {
53+ //console.log(indentation + " \""+index+"\" : [")
54+ print ( item , indentation2 ) ;
55+ } )
56+ console . log ( indentation + "]," )
57+ } else {
58+ console . log ( indentation + " \"" + key + "\" : {" )
59+ print ( node , indentation2 ) ;
60+ console . log ( indentation + "}," )
61+ }
62+ } ) ;
63+ console . log ( indentation + "}," )
64+ }
65+ console . log ( indentation + "}," )
66+ }
67+ }
0 commit comments