Convert date from xml to json to save in mongodb

0

Good afternoon. I currently have an XML where I have several data, one of them is a date. With the help of C # I get that date and then I need to insert it in mongodb with date format.

The date reaches me like this:

<FechaVencimiento>2024-01-01T00:00:00</FechaVencimiento>

I hope I have been clear and you can help me. Thanks.

    
asked by Memo 15.03.2017 в 00:20
source

1 answer

1

First use the Nuget Packager to download the package "newtonsoft json.net"

Then it's as easy as the following 3 lines of code:

XmlDocument documento = new XmlDocument();
documento.LoadXml(xml);
string miJson = JsonConvert.SerializeXmlNode(documento);
    
answered by 15.03.2017 в 15:08