Skip to main content

Posts

Showing posts with the label XML

Create XML and write to file

static void WriteXml(Args _args) { XmlDocument xmlDoc; XmlElement xmlRoot; XmlElement xmlField; XmlElement xmlRecord; XMLWriter xmlWriter; CarTable carTable; DictTable dTable = new DictTable(tablenum(CarTable)); DictField dField; int i, fieldId; str value; #CarsXmlTags ; // Create a new object of the XmlDocument class xmlDoc = XmlDocument::newBlank(); // Create the root node xmlRoot = xmlDoc.createElement(#CarRootNode); // Loop through all the records in the carTable while select carTable { // Create a XmlElement (record) to hold the // contents of the current record. xmlRecord = xmlDoc.createElement(#CarRecords); // Loop through all the fields in the record for (i=1; i<=dTable.fieldCnt(); i++) { // Get the fieldId from the field-count fieldId = dTable.fieldCnt2Id(i); // Find the DictField object that matches // the fieldId dField = dTable.fieldObject(fieldId); // Skip system fields