src/Service/ioService.php
public function importXML($objName)
    {
        // read in file from $_FILE
        // read in file data and attributes
        foreach ($_FILES as $file) {
            $error = $file['error'];
            if ($error != 0) {
                $this->reportError($error);
                return;
            }

            $tmpName = $file['tmp_name'];
            $xml = simplexml_load_file($tmpName);
            if (!$xml) {
                $errorMsg = "Invalid input data format, could not create xml object.";
                Openbizx::$app->getClientProxy()->showErrorMessage($errorMsg);
                return;
            }
            // only read the first one
            break;
        }

        // get the current UI bizobj
        /* @var $form EasyForm */
        $form = Openbizx::getObject($objName);    // get the existing bizform object
        /* @var $parentForm EasyForm */
        $parentForm = Openbizx::getObject($form->GetParentForm());
        /* @var $dataObj BizDataObj */
        $dataObj = $parentForm->getDataObj();

        //$oldCacheMode = $dataObj->GetCacheMode();
        //$dataObj->SetCacheMode(0);    // turn off cache mode, not affect the current cache
        // check if BizDataObj name matches
        $dataObjName = $xml['Name'];
        if ($dataObj->objectName != $$dataObjName) {
            $errorMsg = "Invalid input data. Input data object is not same as the current data object.";
            Openbizx::$app->getClientProxy()->showErrorMessage($errorMsg);
            return;
        }

        // read records
        foreach ($xml->Record as $record) {
            // insert record
            // todo: check if there's same user keys in the table
            $recArray = null;
            $recArray = $dataObj->newRecord();
            foreach ($record as $field) {
                $value = "";
                foreach ($field->attributes() as $attributeName => $attributeValue) {
                    if ($attributeName == 'Name') {
                        $name = $attributeValue . "";
                    } else if ($attributeName == 'Value') {
                        $value = $attributeValue . "";
                    }
                }
                if ($name != "Id") {
                    $recArray[$name] = $value;
                }
            }

            if (!$dataObj->insertRecord($recArray)) {
                $errorMsg = $dataObj->getErrorMessage();
                Openbizx::$app->getClientProxy()->showErrorMessage($errorMsg);
                return;
            }
        }
        $form->setFormState(1); // indicate the import is done
    }
public function importXML($objName)
    {
        // read in file from $_FILE
        // read in file data and attributes
        foreach ($_FILES as $file) {
            $error = $file['error'];
            if ($error != 0) {
                $this->reportError($error);
                return;
            }

            $tmpName = $file['tmp_name'];
            $xml = simplexml_load_file($tmpName);
            if (!$xml) {
                $errorMsg = "Invalid input data format, could not create xml object.";
                Openbizx::$app->getClientProxy()->showErrorMessage($errorMsg);
                return;
            }
            // only read the first one
            break;
        }

        // get the current UI bizobj
        /* @var $form EasyForm */
        $form = Openbizx::getObject($objName);    // get the existing bizform object
        /* @var $parentForm EasyForm */
        $parentForm = Openbizx::getObject($form->GetParentForm());
        /* @var $dataObj BizDataObj */
        $dataObj = $parentForm->getDataObj();

        //$oldCacheMode = $dataObj->GetCacheMode();
        //$dataObj->SetCacheMode(0);    // turn off cache mode, not affect the current cache
        // check if BizDataObj name matches
        $dataObjName = $xml['Name'];
        if ($dataObj->objectName != $$dataObjName) {
            $errorMsg = "Invalid input data. Input data object is not same as the current data object.";
            Openbizx::$app->getClientProxy()->showErrorMessage($errorMsg);
            return;
        }

        // read records
        foreach ($xml->Record as $record) {
            // insert record
            // todo: check if there's same user keys in the table
            $recArray = null;
            $recArray = $dataObj->newRecord();
            foreach ($record as $field) {
                $value = "";
                foreach ($field->attributes() as $attributeName => $attributeValue) {
                    if ($attributeName == 'Name') {
                        $name = $attributeValue . "";
                    } else if ($attributeName == 'Value') {
                        $value = $attributeValue . "";
                    }
                }
                if ($name != "Id") {
                    $recArray[$name] = $value;
                }
            }

            if (!$dataObj->insertRecord($recArray)) {
                $errorMsg = $dataObj->getErrorMessage();
                Openbizx::$app->getClientProxy()->showErrorMessage($errorMsg);
                return;
            }
        }
        $form->setFormState(1); // indicate the import is done
    }
Import from XML file, the file read from client (uploaded by user)

@param string $objName
@return void