xonomy icon indicating copy to clipboard operation
xonomy copied to clipboard

CDATA in mind?

Open HugoMaza opened this issue 6 years ago • 2 comments

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.

HugoMaza avatar Mar 07 '18 01:03 HugoMaza

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.

kdojeteri avatar Apr 12 '18 12:04 kdojeteri

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}, });

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

dnnnvx avatar Dec 20 '18 11:12 dnnnvx