0

I am using xml2js provided by node.

Right now I receive XML from mobile client for chat purpose and they can't control the flow of xml.

So I receive xml like -

<presence id="5zQIb-45" type="available"></presence><message id="5zQIb-44" to="singlechat_1222_1265_1473070385075@conference.mobdev3" type="groupchat"><body>5zQIb-44|$|$|$|$|$|$|Hello Message</body><request xmlns="urn:xmpp:receipts"/></message>

Now when I parse this I get only first xml that is presence json like this-

{"presence":{"$":{"id":"5zQIb-45","type":"available"}}}

The message xml is not parsed.

Can anyone please suggest how to solve it.

prateek3636
  • 155
  • 1
  • 7

1 Answers1

0

Thanks @cartant - I have resolved with adding root xml. After that I have to little bit calculation using xml2js. But now It's working fine.

prateek3636
  • 155
  • 1
  • 7
  • You can also try [fast-xml-parser](https://naturalintelligence.github.io/fast-xml-parser/) to ignore wrapping it in root node. However having single node on root is the correct approach. – Amit Kumar Gupta Apr 18 '18 at 07:31