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

CDATA in mind? #28

Open
HugoMaza opened this issue Mar 7, 2018 · 2 comments
Open

CDATA in mind? #28

HugoMaza opened this issue Mar 7, 2018 · 2 comments

Comments

@HugoMaza
Copy link

HugoMaza commented Mar 7, 2018

Hi michmech,

I was trying to use Xonomy in one of my project (automation) and it's awesome, it's so easy to use. I like it so much.
The only thing I miss from xonomy is the ability to use CDATA.
As one part of my project (it's here in github too) depends a lot on this feature, I wondering if you've planned to add that in a short time.
If there are something I can help you with, please let me know.

Thanks in advance for any response.

@kdojeteri
Copy link

CDATA would be nice. My company needs some hand-authoring done in our XML files and I thought xonomy would be amazing for this. It's unfortunate that there's no support right now.

@dnnnvx
Copy link

dnnnvx commented Dec 20, 2018

In the Xonomy.xml2js function, it checks only the child.nodeType 1 or 3 (element or text). The CDATA type is 4, so just add the relative check:

if(child.nodeType==1) { //element node
	js["children"].push(Xonomy.xml2js(child, js));
}
if(child.nodeType==3) { //text node
	js["children"].push({type: "text", value: child.nodeValue, htmlID: "", parent: function(){return js}, });
}
// ADD THIS -------------------------------------------
if(child.nodeType==4) { //CDATA node
	js["children"].push({type: "text", value: child.nodeValue, htmlID: "", parent: function(){return js}, });

// ----------------------------------------------------------
}

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

No branches or pull requests

3 participants