Skip to content

create a new variable#68

Open
dty717 wants to merge 2 commits into
abdolence:masterfrom
dty717:master
Open

create a new variable#68
dty717 wants to merge 2 commits into
abdolence:masterfrom
dty717:master

Conversation

@dty717
Copy link
Copy Markdown

@dty717 dty717 commented May 15, 2018

I just use a new variable arrAttrNode,

when a node is included in arrAttrNode,
it will display as attribute,not as a node.
e.x.
var x2js = new X2JS();
var jsonObj = {
div : {
id: 'side-nav',
ul:{ id: 'nav'},
}
};

x2js.arrAttrNode.push("id");
var xmlAsStr = x2js.json2xml_str( jsonObj );
console.log(xmlAsStr);

out:

    dty717 added 2 commits May 15, 2018 13:13
    when a node is included in arrAttrNode,
    it will display as attribute,not as a node.
    e.x.
    	var x2js = new X2JS();
    	var jsonObj = {
    		div : {
    			id: 'side-nav',
    			ul:{ id: 'nav'},
    		  }
    	};
    
    	x2js.arrAttrNode.push("id");
    	var xmlAsStr = x2js.json2xml_str( jsonObj );
    	console.log(xmlAsStr);
     out:
    <div id="side-nav" ><ul id="nav" ></ul></div>
    when a node is included in arrAttrNode,
    it will display as attribute,not as a node.
    e.x.
    	var x2js = new X2JS();
    	var jsonObj = {
    		div : {
    			id: 'side-nav',
    			ul:{ id: 'nav'},
    		  }
    	};
    
    	x2js.arrAttrNode.push("id");
    	var xmlAsStr = x2js.json2xml_str( jsonObj );
    	console.log(xmlAsStr);
     out:
    <div id="side-nav" ><ul id="nav" ></ul></div>
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    1 participant