Skip to main content
1-Visitor
December 12, 2019
Question

Read XML data and add to infotable

  • December 12, 2019
  • 1 reply
  • 2047 views

This is my xml file

 

sk36_0-1576190246910.png

 

--------------------------------------------------------------------------------------------------------------

This is my code -

 

var xmlDocument= me.XMLReceivedMessage;

// create info table from data shape
var params = {

infoTableName : "infoTable",

dataShapeName : "US_NRV_Factory_Dash_QULIS_DataShape"

};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(xmlParserTable)
var infoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

// iterate through xml and add to info table
for each (var tag in xmlDocument.DataArea.QualityDeviationRemark) {
var newRow = Object();
newRow.ChassisNumber = tag.DataArea.QualityDeviationRemark.ChassisNo;
newRow.CreationDateTime = tag.DataArea.QualityDeviationRemark.CreationDateTime;
newRow.ProblemType = tag.DataArea.QualityDeviationRemark.ProblemType;
newRow.ProblemDetails = tag.DataArea.QualityDeviationRemark.ProblemDetails;
newRow.ReportingArea = tag.DataArea.QualityDeviationRemark.ReportingArea;
infoTable.AddRow(newRow);
}

// return info table

var result = infoTable;

 

Can someone please help me. It says no data each time I execute. 

1 reply

23-Emerald IV
December 12, 2019

What's your intention:

- Do you need to read the data from the file

or

- Do you need your program to work.

 

In the first case: Use MsExcel to open the file. It reports that some schema's are missing, and offers to create them for you, then you get results.

In the second case: Make sure you get access to Volvo's schema's....

 

Success!
Luc

sk361-VisitorAuthor
1-Visitor
December 12, 2019

Sorry I changed my xml file. I updated the new one. I am able to access the xml file. 

 

When I do this newRow.ChassisNumber = tag.DataArea.QualityDeviationRemark.ChassisNo;

 I do not get the data though. It gives me a infotable saying no data as output

23-Emerald IV
December 12, 2019

That's not a direct answer to my question...

 

And your 'updated xml file' is NOT a valid xml file, apart from the fact that it's a picture of file contents.

 

Here's a picture of (part of the) structure and data of your original file:

LucMeekes_0-1576191010215.png

(Start at the top right).