Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create a new variable #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

create a new variable #68

wants to merge 2 commits into from

Conversation

dty717
Copy link

@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:

    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