PDA

View Full Version : how to escape colon (:) in XML for XML Reader in extjs 4



sgarg
23 Dec 2013, 11:26 PM
I am not able to load xml which has colon in attribute name, i am using extjs-4.2.1
my sample xml

<RDF> <Seq about="urn:productManagement:root" type="ROOT" ac:maxLevels="25"> <li> <Description ac:name="name1" ac:type="type1"/> </li> </Seq></RDF>Model for above xml

Ext.define('TR.model.TreeControlModel', { extend: 'Ext.data.Model', fields: [ { name: 'about', mapping:'@about'}, { name: 'type', mapping:'li>Description@ac:type'}, { name: "name", mapping:'li>Description@ac:name'} ]});I tried replacing : with | (pipe) but it didn't work for me. Need help.

Malte123
25 Dec 2013, 6:54 PM
I would do this by prefiltering the xml input by using

var parser=new DOMParser();
var xml = parser.parseFromString(xmltext,'text/xml');
// loop each xml elementNode and set Namespace to ''
//:
//:
elementNode.setAttributeNS(ns,name,value) // value should be '' ... maybe this will do the job
//:
//:
// each end
console.log(xml); // should be without namespace .. so no colons in ?!? *hope*


take a look at http://www.w3schools.com/dom/met_element_setattributens.asp

Hope this trick works - please feedback for community :-)

I think an other way you will not find - I have done a lot with xml an extjs - and extjs likes JSON only ... but if you know how to handle xml-input ... you can find a way to make input extjs-compatible

Good luck :)