oozcitak / xmlbuilder-js

An XML builder for node.js
MIT License
919 stars 108 forks source link

separateArrayItems doesn't seem to work #229

Closed pconnell99 closed 4 years ago

pconnell99 commented 4 years ago

I'm trying to create an array like:-

'pnp:ContentTypeBindings': [{
     'pnp:ContentTypeBinding': { "@ContentTypeID": "0x0101", "@Default": "true" }
        },
        {
            'pnp:ContentTypeBinding': { "@ContentTypeID": "0x0120" }
        }]

Expecting:-

<pnp:ContentTypeBindings>
            <pnp:ContentTypeBinding ContentTypeID="0x0101" Default="true" />
            <pnp:ContentTypeBinding ContentTypeID="0x0120" />
          </pnp:ContentTypeBindings>

But getting:-

 <pnp:ContentTypeBindings>
            <pnp:ContentTypeBinding ContentTypeID="0x0101" Default="true"/>
 </pnp:ContentTypeBindings>
  <pnp:ContentTypeBindings>
            <pnp:ContentTypeBinding ContentTypeID="0x0120"/>
 </pnp:ContentTypeBindings>

separateArrayItems is set to default false, so I was hoping this would aggregate them. These elements are being built as objects and then passed into an ele() call off the previous parent object.

Thoughts? Am I doing this wrong?

pconnell99 commented 4 years ago

I have to build up the object dynamically as I go, so using chaining will not work - am I losing context by not chaining the calls? I'm creating objects off the back of the previous object.

oozcitak commented 4 years ago

Try with separateArrayİtems set to true please.

pconnell99 commented 4 years ago

Worked (had not previously oddly enough). Thanks, closing.