File tree Expand file tree Collapse file tree 3 files changed +9
-0
lines changed
Expand file tree Collapse file tree 3 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,12 @@ module.exports = class XMLNode
4646 @ attribute (attKey .substr (@stringify .convertAttKey .length ), attVal)
4747 delete name[attKey]
4848
49+ # assign processing instructions and remove from this object
50+ for own piKey, piVal of name
51+ if @stringify .convertPIKey and piKey .indexOf (@stringify .convertPIKey ) == 0
52+ @ instruction (piKey .substr (@stringify .convertPIKey .length ), piVal)
53+ delete name[piKey]
54+
4955 # insert children
5056 for own key, val of name
5157
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ module.exports = class XMLStringifier
5959
6060 # strings to match while converting from JS objects
6161 convertAttKey : ' @'
62+ convertPIKey : ' !'
6263 convertTextKey : ' #text'
6364 convertCDataKey : ' #cdata'
6465 convertCommentKey : ' #comment'
Original file line number Diff line number Diff line change 6060 person :
6161 name : " John"
6262 ' @age' : 35
63+ ' !pi' : ' mypi'
6364 ' #comment' : ' Good guy'
6465 ' #cdata' : ' well formed!'
6566 unescaped :
8384 ' resulting XML ' : (topic ) ->
8485 xml = ' <root>' +
8586 ' <ele>simple element</ele>' +
87+ ' <?pi mypi?>' +
8688 ' <person age="35">' +
8789 ' <name>John</name>' +
8890 ' <!-- Good guy -->' +
You can’t perform that action at this time.
0 commit comments