File tree 3 files changed +9
-0
lines changed
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
46
46
@ attribute (attKey .substr (@stringify .convertAttKey .length ), attVal)
47
47
delete name[attKey]
48
48
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
+
49
55
# insert children
50
56
for own key, val of name
51
57
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ module.exports = class XMLStringifier
59
59
60
60
# strings to match while converting from JS objects
61
61
convertAttKey : ' @'
62
+ convertPIKey : ' !'
62
63
convertTextKey : ' #text'
63
64
convertCDataKey : ' #cdata'
64
65
convertCommentKey : ' #comment'
Original file line number Diff line number Diff line change 60
60
person :
61
61
name : " John"
62
62
' @age' : 35
63
+ ' !pi' : ' mypi'
63
64
' #comment' : ' Good guy'
64
65
' #cdata' : ' well formed!'
65
66
unescaped :
83
84
' resulting XML ' : (topic ) ->
84
85
xml = ' <root>' +
85
86
' <ele>simple element</ele>' +
87
+ ' <?pi mypi?>' +
86
88
' <person age="35">' +
87
89
' <name>John</name>' +
88
90
' <!-- Good guy -->' +
You can’t perform that action at this time.
0 commit comments