javascript - Issue while converting from JSON to XML -


when converting below json xml, seems __text property being stripped off xml.

{     "root": {         "number": {             "__text": "1\n-\n222\n-\n500"         }     } } 

can tell how __text property changes , __text represents?

below fiddle , library used

http://jsfiddle.net/abdmob/gtlbx/15/

https://code.google.com/p/x2js/

the __text property changes javascript syntax of multi-line string xml syntax of multi-line string. means \n converted newline.

1\n-\n222\n-\n500

will become

1 - 222 - 500 

which same, in different notation

without knowing library you're using, i'd guess __text represents content of property you're describing.

looking source of library seems _ indicates attribute , attribute __text special attribute indicate text contained inside xml element when element has attributes.

here updated fiddle should understand better: https://jsfiddle.net/gtlbx/924/

here source code snippets, imply things assumed:

  1. _ attribute, because of line 31:

    config.attributeprefix = config.attributeprefix || "_";

  2. _text name of internal attribute, because of this line 272:

    result.__text = result.__text.join("\n");


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -