i got a problem when parsing an XML to JSON by using xml2js. Here's my xml.
<Tables>
<Table>
<Id>TABLE1</Id>
<Description>Test 1</Description>
<FullName>TEST.CHEM.Customer</FullName>
<Columns>
<Column>
<Id>1</Id>
<Name>CustomerId</Name>
<DataType>Number</DataType>
</Column>
<Column>
<Id>2</Id>
<Name>CustomerName</Name>
<DataType>String</DataType>
</Column>
<Column>
<Id>2</Id>
<Name>ValidFrom</Name>
<DataType>Date</DataType>
</Column>
</Columns>
</Table></Tables>
And here's my main. I follow snippet from that library for the figuredOutXML (input: xmlfile.parseString, output: data)
apiRoutes.get('/test', function(req, res) {
res.set('Content-Type', 'application/json');
figuredOutXML(function(err,data,data2){
if(err){
console.log("Error!");
console.error(err.message);
}else{
var tableId = util.inspect(data2.Tables.Table.Id, false, null);
res.status(200).send(JSON.stringify({
INFO: 'SUCCESS',
TABLE: tableId}));
}
});
But i got undefined result for tableId
. Is it something wrong with xml or the function?