xml-js
xml-js copied to clipboard
Converts multiple comments when using json2xml() function
When converting JavaScript Object/JSON to XML, sometimes it needs to have more than one comment.
For example, the following JSON object has two comments:
{
"comment1": "Comment for title",
"title": "Happy",
"comment2": "Comment for todo",
"todo": "Work"
}
Corresponding XML object should look like this:
<!--Comment for title-->
<title>Happy</title>
<!--Comment for todo-->
<todo>Work</todo>
In this commit, json2xml()
function makes it possible by regarding any name of the property key which starts with options.commentKey
as key for comment property. For example, if options.commentKey
is $comment
, then $comment1
, $comment_title
as well as $comment
are regarded as keys for comment property.