node-xml
node-xml copied to clipboard
Self-closing tag
Hello! Thx for your package! Could you please tell, how I could create such tag SOAP-ENV:Header/
I tried { 'SOAP-ENV:Header': [] },but it becomes SOAP-ENV:Header </SOAP-ENV:Header> Not self-closing tag
Hi, i think you mean something like this:
xml({
'myTag': [],
})
this will build into
<myTag></myTag>
i assume you want it to result in <myTag/>
?
i have had the same issue and found that if you set the value of your tag to null. it will close it's own tag
(eg: xml({ myTag: null })
)
this is a neat feature, but it doesn't seem work when dealing with _attr
. for example:
xml({
myTag: [
{ _attr: { myAttrib: "myVal" } }
]
})
will result in <myTag myAttrib="myVal"></myTag>
i hope this helps. and i hope this feature could be added with maybe a closeEmptyElement
option.