Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-closing tag #42

Open
Griha3212 opened this issue Jun 15, 2020 · 1 comment
Open

Self-closing tag #42

Griha3212 opened this issue Jun 15, 2020 · 1 comment

Comments

@Griha3212
Copy link

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

@Natejoestev
Copy link

Natejoestev commented May 25, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants