Quellcode durchsuchen

Eliminar el esquema de los nodos. Procesar los nodos mas facilmente visibles del xml

Nermosis vor 3 Jahren
Ursprung
Commit
021a79a8e0

+ 19 - 19
application/config/autoload.php Datei anzeigen

@@ -1,5 +1,5 @@
1 1
 <?php
2
-defined('BASEPATH') OR exit('No direct script access allowed');
2
+defined('BASEPATH') or exit('No direct script access allowed');
3 3
 
4 4
 /*
5 5
 | -------------------------------------------------------------------
@@ -28,7 +28,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
28 28
 | 6. Language files
29 29
 | 7. Models
30 30
 |
31
-*/
31
+ */
32 32
 
33 33
 /*
34 34
 | -------------------------------------------------------------------
@@ -38,7 +38,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
38 38
 |
39 39
 |  $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
40 40
 |
41
-*/
41
+ */
42 42
 $autoload['packages'] = array();
43 43
 
44 44
 /*
@@ -51,13 +51,13 @@ $autoload['packages'] = array();
51 51
 |
52 52
 | Prototype:
53 53
 |
54
-|	$autoload['libraries'] = array('database', 'email', 'session');
54
+|    $autoload['libraries'] = array('database', 'email', 'session');
55 55
 |
56 56
 | You can also supply an alternative library name to be assigned
57 57
 | in the controller:
58 58
 |
59
-|	$autoload['libraries'] = array('user_agent' => 'ua');
60
-*/
59
+|    $autoload['libraries'] = array('user_agent' => 'ua');
60
+ */
61 61
 $autoload['libraries'] = array();
62 62
 
63 63
 /*
@@ -71,14 +71,14 @@ $autoload['libraries'] = array();
71 71
 |
72 72
 | Prototype:
73 73
 |
74
-|	$autoload['drivers'] = array('cache');
74
+|    $autoload['drivers'] = array('cache');
75 75
 |
76 76
 | You can also supply an alternative property name to be assigned in
77 77
 | the controller:
78 78
 |
79
-|	$autoload['drivers'] = array('cache' => 'cch');
79
+|    $autoload['drivers'] = array('cache' => 'cch');
80 80
 |
81
-*/
81
+ */
82 82
 $autoload['drivers'] = array();
83 83
 
84 84
 /*
@@ -87,9 +87,9 @@ $autoload['drivers'] = array();
87 87
 | -------------------------------------------------------------------
88 88
 | Prototype:
89 89
 |
90
-|	$autoload['helper'] = array('url', 'file');
91
-*/
92
-$autoload['helper'] = array();
90
+|    $autoload['helper'] = array('url', 'file');
91
+ */
92
+$autoload['helper'] = array("funciones");
93 93
 
94 94
 /*
95 95
 | -------------------------------------------------------------------
@@ -97,12 +97,12 @@ $autoload['helper'] = array();
97 97
 | -------------------------------------------------------------------
98 98
 | Prototype:
99 99
 |
100
-|	$autoload['config'] = array('config1', 'config2');
100
+|    $autoload['config'] = array('config1', 'config2');
101 101
 |
102 102
 | NOTE: This item is intended for use ONLY if you have created custom
103 103
 | config files.  Otherwise, leave it blank.
104 104
 |
105
-*/
105
+ */
106 106
 $autoload['config'] = array();
107 107
 
108 108
 /*
@@ -111,12 +111,12 @@ $autoload['config'] = array();
111 111
 | -------------------------------------------------------------------
112 112
 | Prototype:
113 113
 |
114
-|	$autoload['language'] = array('lang1', 'lang2');
114
+|    $autoload['language'] = array('lang1', 'lang2');
115 115
 |
116 116
 | NOTE: Do not include the "_lang" part of your file.  For example
117 117
 | "codeigniter_lang.php" would be referenced as array('codeigniter');
118 118
 |
119
-*/
119
+ */
120 120
 $autoload['language'] = array();
121 121
 
122 122
 /*
@@ -125,11 +125,11 @@ $autoload['language'] = array();
125 125
 | -------------------------------------------------------------------
126 126
 | Prototype:
127 127
 |
128
-|	$autoload['model'] = array('first_model', 'second_model');
128
+|    $autoload['model'] = array('first_model', 'second_model');
129 129
 |
130 130
 | You can also supply an alternative model name to be assigned
131 131
 | in the controller:
132 132
 |
133
-|	$autoload['model'] = array('first_model' => 'first');
134
-*/
133
+|    $autoload['model'] = array('first_model' => 'first');
134
+ */
135 135
 $autoload['model'] = array();

+ 33 - 28
application/controllers/FileDownload.php Datei anzeigen

@@ -5,32 +5,20 @@ class FileDownload extends CI_Controller
5 5
 {
6 6
 
7 7
     protected $rutaDiaria = FCPATH . "DOWNLOADS/DAILY/";
8
+    protected $rutaDiariaFormat = FCPATH . "DOWNLOADS/DAILY/format/";
8 9
     protected $rutaMensual = FCPATH . "DOWNLOADS/MONTH/";
9 10
     protected $enlaceAtom = "";
10 11
 
11 12
     public function __construct()
12 13
     {
13 14
         parent::__construct();
14
-        $this->load->library('Feed');
15 15
         $this->load->helper('file');
16 16
         $this->load->helper('xml');
17
-
18 17
     }
19 18
 
20 19
     public function index()
21 20
     {
22
-        $files = get_filenames($this->rutaDiaria, true);
23
-
24
-        foreach ($files as $file) {
25
-            $entrada = file_get_contents($file);
26
-            $xml = new SimpleXMLElement($entrada);
27
-            $deletedEntrys = $xml->children('at', true);
28
-
29
-            $result1 = $xml->entry->children('cac-place-ext', true);
30
-            $result2 = $xml->entry->children('cac-place-ext', true)->ContractFolderStatus->children('cac-place-ext', true);
31
-            $result3 = $xml->entry->children('cac-place-ext', true)->ContractFolderStatus->children('cac', true);
32
-            $result4 = $xml->entry->children('cac-place-ext', true)->ContractFolderStatus->children('cbc', true);
33
-        }
21
+        $this->downloadProcess();
34 22
     }
35 23
 
36 24
     private function downloadProcess()
@@ -38,20 +26,23 @@ class FileDownload extends CI_Controller
38 26
         $fileName = basename(URL_DIARIA);
39 27
         $this->downloadFile($fileName, URL_DIARIA, $this->rutaDiaria);
40 28
 
41
-        $archivoAtom = $this->getFile($this->rutaDiaria . $fileName);
29
+        $archivoAtom = $this->getFile($this->rutaDiaria . $fileName, $fileName);
42 30
         $nuevoAtomAttrNext = $this->readNextAttribute($archivoAtom);
43 31
 
44
-        while ($nuevoAtomAttrNext !== "") {
32
+        //while ($nuevoAtomAttrNext !== "") {
33
+        $aux = 0;
34
+        while ($aux <= 3) {
45 35
 
46 36
             $fileName = basename($nuevoAtomAttrNext);
47 37
             $this->downloadFile($fileName, $nuevoAtomAttrNext, $this->rutaDiaria);
48
-            $archivoAtom = $this->getFile($this->rutaDiaria . $fileName);
38
+            $archivoAtom = $this->getFile($this->rutaDiaria . $fileName, $fileName);
49 39
 
50 40
             $nuevoAtomAttrNext = $this->readNextAttribute($archivoAtom);
41
+            $aux++;
51 42
         }
52 43
     }
53 44
 
54
-    private function getFile($url = URL_DIARIA)
45
+    private function getFile($url = URL_DIARIA, $fileName)
55 46
     {
56 47
 
57 48
         $feed = implode(file($url));
@@ -59,9 +50,17 @@ class FileDownload extends CI_Controller
59 50
         $json = json_encode($xml);
60 51
         $array = json_decode($json, true);
61 52
 
53
+        $this->formatXml($feed, $fileName);
62 54
         return $array;
63 55
     }
64 56
 
57
+    private function formatXml($xml, $fileName)
58
+    {
59
+        $openingFormat = $this->regExIniciosEsquema($xml);
60
+        $closureFormat = $this->regExFinalesEsquema($openingFormat);
61
+        file_put_contents($this->rutaDiariaFormat . $fileName, $closureFormat);
62
+    }
63
+
65 64
     private function readNextAttribute($archivo)
66 65
     {
67 66
         $enlace = "";
@@ -77,16 +76,6 @@ class FileDownload extends CI_Controller
77 76
         return $enlace;
78 77
     }
79 78
 
80
-    private function newFolder($rutaFinal)
81
-    {
82
-        $result = false;
83
-        if (!is_dir($rutaFinal)) {
84
-            $result = mkdir($rutaFinal);
85
-        }
86
-
87
-        return $result;
88
-    }
89
-
90 79
     private function downloadFile($fileName, $url, $ruta)
91 80
     {
92 81
         if (file_put_contents($ruta . $fileName, file_get_contents($url))) {
@@ -96,4 +85,20 @@ class FileDownload extends CI_Controller
96 85
         }
97 86
     }
98 87
 
88
+    private function regExIniciosEsquema($xml)
89
+    {
90
+        $pattern = "/(<cac:)|(<cbc:)|(<cac-place-ext:)|(<cbc-place-ext:)/";
91
+        $result = preg_replace($pattern, "<", $xml);
92
+
93
+        return $result;
94
+    }
95
+
96
+    private function regExFinalesEsquema($xml)
97
+    {
98
+        $pattern = "/(<\/cac:)|(<\/cbc:)|(<\/cac-place-ext:)|(<\/cbc-place-ext:)/";
99
+        $result = preg_replace($pattern, "</", $xml);
100
+
101
+        return $result;
102
+    }
103
+
99 104
 }

+ 516 - 0
application/controllers/ParserFile.php Datei anzeigen

@@ -0,0 +1,516 @@
1
+<?php
2
+defined('BASEPATH') or exit('No direct script access allowed');
3
+
4
+class ParserFile extends CI_Controller
5
+{
6
+    protected $rutaDiaria = FCPATH . "DOWNLOADS/DAILY/format";
7
+    protected $rutaMensual = FCPATH . "DOWNLOADS/MONTH/format";
8
+    protected $esquema = array('cbc-place-ext', 'cac-place-ext', 'cbc', 'cac', 'ns1');
9
+
10
+    public function __construct()
11
+    {
12
+        parent::__construct();
13
+        $this->load->helper('file');
14
+    }
15
+
16
+    public function index()
17
+    {
18
+        $files = get_filenames($this->rutaDiaria, true);
19
+
20
+        $contadorArchivos = 0;
21
+        foreach ($files as $file) {
22
+
23
+            $entrada = file_get_contents($file);
24
+            $xml = simplexml_load_string($entrada);
25
+
26
+            $aux = 0;
27
+            $resultEntries = array();
28
+            foreach ($xml->entry as $clave => $row) {
29
+                $arrayDeletedEntries = $xml->children('at', true);
30
+
31
+                $resultEntries[$aux]['contractInfo'] = $this->nodoContractFolderStatus($row);
32
+
33
+                $resultEntries[$aux]['locatedContractingParty'] = $this->nodoLocatedContractingParty($row);
34
+
35
+                $resultEntries[$aux]['party'] = $this->nodoParty($row);
36
+
37
+                //$resultEntries[] = $this->nodoParentLocatedParty($row);
38
+
39
+                $resultEntries[$aux]['procurementProject'] = $this->nodoPresupuesto($row);
40
+
41
+                $resultEntries[$aux]['procurementProjectLot'] = $this->nodoProcurementProjectLot($row);
42
+
43
+                $resultEntries[$aux]['tenderingTerms'] = $this->nodoTenderingTerms($row);
44
+
45
+                $resultEntries[$aux]['tenderingProcess'] = $this->nodoTenderingProcess($row);
46
+
47
+                $resultEntries[$aux]['tenderingResult'] = $this->nodoTenderResult($row);
48
+
49
+                $resultEntries[$aux]['legalDocs'] = $this->nodoLegalDoc($row);
50
+
51
+                $resultEntries[$aux]['techicalDocs'] = $this->nodoTechnicalDocumentReference($row);
52
+
53
+                $resultEntries[$aux]['validNoticeInfo'] = $this->nodoValidNoticeInfo($row);
54
+
55
+                $resultEntries[$aux]['generalDocs'] = $this->nodoGeneralDocuments($row);
56
+
57
+                $resultEntries[$aux]['additionalDocs'] = $this->nodoAdditionalDocumentReference($row);
58
+
59
+                $aux++;
60
+            }
61
+
62
+            $str = print_r($resultEntries, true);
63
+
64
+            file_put_contents($this->rutaDiaria . "/text" . $contadorArchivos . ".txt", $str);
65
+
66
+            $contadorArchivos++;
67
+
68
+        }
69
+    }
70
+
71
+    private function nodoContractFolderStatus($xml)
72
+    {
73
+        $resultEntries = array();
74
+        if (isset($xml->ContractFolderStatus)) {
75
+            $resultEntries['ContractFolderID'] = (string) $xml->ContractFolderStatus->ContractFolderID;
76
+            $resultEntries['ContractFolderStatusCode'] = (string) $xml->ContractFolderStatus->ContractFolderStatusCode;
77
+            $resultEntries['ContractFolderStatusCodeAttr'] = (string) $xml->ContractFolderStatus->ContractFolderStatusCode->attributes()['listURI'];
78
+        }
79
+        $resultFinal = $this->array_remove_empty($resultEntries);
80
+        return $resultFinal;
81
+    }
82
+
83
+    private function nodoLocatedContractingParty($xml)
84
+    {
85
+        $resultEntries = array();
86
+        if (isset($xml->ContractFolderStatus->LocatedContractingParty)) {
87
+            $LocatedContractingParty = $xml->ContractFolderStatus->LocatedContractingParty;
88
+
89
+            $resultEntries['contractingPartyTypeCode'] = $this->existNodo($LocatedContractingParty, "ContractingPartyTypeCode", 'string');
90
+            $resultEntries['activityCode'] = $this->existNodo($LocatedContractingParty, "ActivityCode", 'string');
91
+            $resultEntries['buyerProfileURIID'] = $this->existNodo($LocatedContractingParty, "BuyerProfileURIID", 'string');
92
+
93
+            if (isset($LocatedContractingParty->ParentLocatedParty)) {
94
+                //$resultEntries['activityCode'] = $this->existNodo($LocatedContractingParty->ParentLocatedParty, "PartyName", 'string');
95
+
96
+                $this->RecurseXML($LocatedContractingParty->ParentLocatedParty);
97
+            }
98
+        }
99
+        $resultFinal = $this->array_remove_empty($resultEntries);
100
+        return $resultFinal;
101
+    }
102
+
103
+    private function nodoParty($xml)
104
+    {
105
+        $resultEntries = array();
106
+        $contractFolder = $xml->ContractFolderStatus->LocatedContractingParty;
107
+
108
+        if (isset($contractFolder->Party)) {
109
+            //Datos Empresa -> direccion,nif, etc
110
+            //LocatedContractingParty->Party
111
+            $party = $contractFolder->Party;
112
+            $resultEntries['websiteURI'] = $this->existNodo($party, "WebsiteURI", 'string');
113
+            $resultEntries['partyIdentification'] = $this->existNodo($party, "PartyIdentification", 'array');
114
+            $resultEntries['partyName'] = $this->existNodo($party->PartyName, "Name", 'string');
115
+            $resultEntries['address']['city'] = $this->existNodo($party->PostalAddress, "CityName", 'string');
116
+            $resultEntries['address']['codpostal'] = $this->existNodo($party->PostalAddress, "PostalZone", 'string');
117
+            $resultEntries['address']['direccion'] = $this->existNodo($party->PostalAddress->AddressLine, "Line", 'string');
118
+            $resultEntries['address']['country'] = $this->existNodo($party->PostalAddress->Country, "Name", 'string');
119
+            $resultEntries['contact']['name'] = $this->existNodo($party->Contact, "Name", 'string');
120
+            $resultEntries['contact']['email'] = $this->existNodo($party->Contact, "ElectronicMail", 'string');
121
+        }
122
+        $resultFinal = $this->array_remove_empty($resultEntries);
123
+        return $resultFinal;
124
+    }
125
+
126
+    private function nodoPresupuesto($xml)
127
+    {
128
+        $resultEntries = array();
129
+
130
+        $procurementProject = $xml->ContractFolderStatus->ProcurementProject;
131
+
132
+        if (isset($procurementProject)) {
133
+            //ProcurementProject
134
+
135
+            $resultEntries['name'] = $this->existNodo($procurementProject, 'Name', 'string');
136
+            $resultEntries['typeCode'] = $this->existNodo($procurementProject, 'TypeCode', 'string');
137
+            $resultEntries['subTypeCode'] = $this->existNodo($procurementProject, 'SubTypeCode', 'string');
138
+
139
+            if (isset($procurementProject->BudgetAmount)) {
140
+                $resultEntries['estimatedOverallContractAmount'] = $this->existNodo($procurementProject->BudgetAmount, 'EstimatedOverallContractAmount', 'string');
141
+                $resultEntries['totalAmount'] = $this->existNodo($procurementProject->BudgetAmount, 'TotalAmount', 'string');
142
+                $resultEntries['taxExclusiveAmount'] = $this->existNodo($procurementProject->BudgetAmount, 'TaxExclusiveAmount', 'string');
143
+            }
144
+
145
+            if (isset($procurementProject->RequiredCommodityClassification)) {
146
+                for ($i = 0; $i < count($procurementProject->RequiredCommodityClassification); $i++) {
147
+                    $resultEntries['itemClassification']['value'] = $this->existNodo($procurementProject->RequiredCommodityClassification[$i], 'ItemClassificationCode', 'string');
148
+                    $resultEntries['itemClassification']['attr'] = $procurementProject->RequiredCommodityClassification[$i]->ItemClassificationCode->attributes();
149
+                }
150
+            }
151
+
152
+            if (isset($procurementProject->RealizedLocation)) {
153
+                $resultEntries['countrySubentity'] = $this->existNodo($procurementProject->RealizedLocation, 'CountrySubentity', 'string');
154
+                $resultEntries['countrySubentityCode'] = $this->existNodo($procurementProject->RealizedLocation, 'CountrySubentityCode', 'string');
155
+                if (isset($procurementProject->RealizedLocation->Address)) {
156
+                    $resultEntries['cityName'] = $this->existNodo($procurementProject->RealizedLocation->Address->Country, 'CityName', 'string');
157
+                    $resultEntries['IdentificationCode'] = $this->existNodo($procurementProject->RealizedLocation->Address->Country, 'IdentificationCode', 'string');
158
+                    $resultEntries['countryName'] = $this->existNodo($procurementProject->RealizedLocation->Address->Country, 'Name', 'string');
159
+                }
160
+            }
161
+
162
+            $resultEntries['durationMesure'] = $this->existNodo($procurementProject->PlannedPeriod, 'DurationMeasure', 'string');
163
+            if (isset($procurementProject->PlannedPeriod->DurationMeasure)) {
164
+                $resultEntries['medida'] = $procurementProject->PlannedPeriod->DurationMeasure->attributes();
165
+            }
166
+
167
+            $resultEntries['contractExtension'] = $this->existNodo($procurementProject->ContractExtension, 'OptionsDescription', 'string');
168
+        }
169
+
170
+        $resultFinal = $this->array_remove_empty($resultEntries);
171
+        return $resultFinal;
172
+    }
173
+
174
+    private function nodoProcurementProjectLot($xml)
175
+    {
176
+        $resultEntries = array();
177
+        $procurementProjectLot = $xml->ContractFolderStatus->ProcurementProjectLot;
178
+
179
+        if (isset($procurementProjectLot)) {
180
+            for ($i = 0; $i < count($procurementProjectLot); $i++) {
181
+                $resultEntries[$i]['id'] = $this->existNodo($procurementProjectLot[$i], 'ID', 'string');
182
+                $resultEntries[$i]['name'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject, 'Name', 'string');
183
+                $resultEntries[$i]['totalAmount'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->BudgetAmount, 'TotalAmount', 'string');
184
+                $resultEntries[$i]['taxExclusiveAmount'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->BudgetAmount, 'TaxExclusiveAmount', 'string');
185
+                $resultEntries[$i]['itemClassificationCode'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->RequiredCommodityClassification, 'ItemClassificationCode', 'string');
186
+                if (isset($procurementProjectLot[$i]->RealizedLocation)) {
187
+                    $resultEntries[$i]['countrySubentity'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->RealizedLocation, 'CountrySubentity', 'string');
188
+                    $resultEntries[$i]['countrySubentityCode'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->RealizedLocation, 'CountrySubentityCode', 'string');
189
+                    $resultEntries[$i]['identificationCode'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->RealizedLocation->Address->Country, 'IdentificationCode', 'string');
190
+                    $resultEntries[$i]['name'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->RealizedLocation->Address->Country, 'Name', 'string');
191
+                }
192
+            }
193
+        }
194
+        $resultFinal = $this->array_remove_empty($resultEntries);
195
+        return $resultFinal;
196
+    }
197
+
198
+    private function nodoTenderResult($xml)
199
+    {
200
+        $resultEntries = array();
201
+        $tenderResult = $xml->ContractFolderStatus->TenderResult;
202
+        for ($i = 0; $i < count($tenderResult); $i++) {
203
+            $resultEntries[$i]['resultCode'] = $this->existNodo($tenderResult[$i], 'ResultCode', 'string');
204
+            $resultEntries[$i]['description'] = $this->existNodo($tenderResult[$i], 'Description', 'string');
205
+            $resultEntries[$i]['awardDate'] = $this->existNodo($tenderResult[$i], 'AwardDate', 'string');
206
+            $resultEntries[$i]['receivedTenderQuantity'] = $this->existNodo($tenderResult[$i], 'ReceivedTenderQuantity', 'string');
207
+            $resultEntries[$i]['lowerTenderAmount'] = $this->existNodo($tenderResult[$i], 'LowerTenderAmount', 'string');
208
+            $resultEntries[$i]['higherTenderAmount'] = $this->existNodo($tenderResult[$i], 'HigherTenderAmount', 'string');
209
+            $resultEntries[$i]['startDate'] = $this->existNodo($tenderResult[$i], 'StartDate', 'string');
210
+            $resultEntries[$i]['smeawardedIndicator'] = $this->existNodo($tenderResult[$i], 'SMEAwardedIndicator', 'string');
211
+            //AwardedTenderedProject
212
+            $resultEntries[$i]['contract']['id'] = $this->existNodo($tenderResult[$i]->Contract, 'ID', 'string');
213
+            $resultEntries[$i]['contract']['issueDate'] = $this->existNodo($tenderResult[$i]->Contract, 'IssueDate', 'string');
214
+
215
+            $winningParty = $tenderResult[$i]->WinningParty;
216
+            if (isset($winningParty)) {
217
+                $resultEntries[$i]['partyIdentification'] = $this->existNodo($winningParty->PartyIdentification, 'ID', 'string');
218
+                $resultEntries[$i]['partyName'] = $this->existNodo($winningParty->PartyName, 'Name', 'string');
219
+            }
220
+            $awardedTenderedProject = $tenderResult[$i]->AwardedTenderedProject;
221
+            if (isset($awardedTenderedProject)) {
222
+                $resultEntries[$i]['procurementProjectLotID'] = $this->existNodo($awardedTenderedProject, 'ProcurementProjectLotID', 'string');
223
+                $resultEntries[$i]['TaxExclusiveAmount'] = $this->existNodo($awardedTenderedProject->LegalMonetaryTotal, 'TaxExclusiveAmount', 'string');
224
+                $resultEntries[$i]['PayableAmount'] = $this->existNodo($awardedTenderedProject->LegalMonetaryTotal, 'PayableAmount', 'string');
225
+            }
226
+        }
227
+        $resultFinal = $this->array_remove_empty($resultEntries);
228
+        return $resultFinal;
229
+    }
230
+
231
+    private function nodoTenderingTerms($xml)
232
+    {
233
+        $resultEntries = array();
234
+        $TenderingTerms = $xml->ContractFolderStatus->TenderingTerms;
235
+
236
+        if (isset($TenderingTerms)) {
237
+
238
+            $resultEntries['requiredCurriculaIndicator'] = $this->existNodo($TenderingTerms, 'RequiredCurriculaIndicator', 'string');
239
+            $resultEntries['variantConstraintIndicator'] = $this->existNodo($TenderingTerms, 'VariantConstraintIndicator', 'string');
240
+            $resultEntries['fundingProgramCode'] = $this->existNodo($TenderingTerms, 'FundingProgramCode', 'string');
241
+            $resultEntries['requiredFinancialGuarantee']['guaranteeTypeCode'] = $this->existNodo($TenderingTerms->RequiredFinancialGuarantee, 'GuaranteeTypeCode', 'string');
242
+            $resultEntries['requiredFinancialGuarantee']['amountRate'] = $this->existNodo($TenderingTerms->RequiredFinancialGuarantee, 'AmountRate', 'string');
243
+            $resultEntries['procurementLegislationDocumentReference'] = $this->existNodo($TenderingTerms->ProcurementLegislationDocumentReference, 'ID', 'string');
244
+
245
+            $tendererQualificationRequest = $TenderingTerms->TendererQualificationRequest;
246
+            if (isset($tendererQualificationRequest)) {
247
+                for ($i = 0; $i < count($tendererQualificationRequest); $i++) {
248
+                    $resultEntries['tendererQualificationRequest']['evaluationCriteriaTypeCode'] = $this->existNodo($tendererQualificationRequest[$i]->TechnicalEvaluationCriteria, 'EvaluationCriteriaTypeCode', 'string');
249
+                    $resultEntries['tendererQualificationRequest']['description'] = $this->existNodo($tendererQualificationRequest[$i]->TechnicalEvaluationCriteria, 'Description', 'string');
250
+                }
251
+            }
252
+
253
+            $financialEvaluationCriteria = $TenderingTerms->TendererQualificationRequest->FinancialEvaluationCriteria;
254
+            if (isset($financialEvaluationCriteria)) {
255
+                for ($i = 0; $i < count($financialEvaluationCriteria); $i++) {
256
+                    $resultEntries['financialEvaluationCriteria']['evaluationCriteriaTypeCode'] = $this->existNodo($financialEvaluationCriteria[$i]->EvaluationCriteriaTypeCode, 'EvaluationCriteriaTypeCode', 'string');
257
+                    $resultEntries['financialEvaluationCriteria']['description'] = $this->existNodo($financialEvaluationCriteria[$i]->EvaluationCriteriaTypeCode, 'Description', 'string');
258
+                }
259
+            }
260
+
261
+            $specificTendererRequirement = $TenderingTerms->TendererQualificationRequest->SpecificTendererRequirement;
262
+            if (isset($specificTendererRequirement)) {
263
+                for ($i = 0; $i < count($specificTendererRequirement); $i++) {
264
+                    $resultEntries['financialEvaluationCriteria']['evaluationCriteriaTypeCode'] = $this->existNodo($specificTendererRequirement[$i]->SpecificTendererRequirement, 'RequirementTypeCode', 'string');
265
+                }
266
+            }
267
+
268
+            //$Language = $this->existNodo($contractFolderCac->TenderingTerms->children('cac', true)->Language, 'cbc', 'array');
269
+        }
270
+        $resultFinal = $this->array_remove_empty($resultEntries);
271
+        return $resultFinal;
272
+    }
273
+
274
+    private function nodoTenderingProcess($xml)
275
+    {
276
+        $resultEntries = array();
277
+        $tenderingProcess = $xml->ContractFolderStatus->TenderingProcess;
278
+
279
+        if (isset($tenderingProcess)) {
280
+            //TenderingProcess
281
+            $resultEntries['procedureCode'] = $this->existNodo($tenderingProcess, 'ProcedureCode', 'string');
282
+            $resultEntries['urgencyCode'] = $this->existNodo($tenderingProcess, 'UrgencyCode', 'string');
283
+            $resultEntries['partPresentationCode'] = $this->existNodo($tenderingProcess, 'PartPresentationCode', 'string');
284
+            $resultEntries['contractingSystemCode'] = $this->existNodo($tenderingProcess, 'ContractingSystemCode', 'string');
285
+            $resultEntries['submissionMethodCode'] = $this->existNodo($tenderingProcess, 'SubmissionMethodCode', 'string');
286
+            $resultEntries['deadLineEndDate'] = $this->existNodo($tenderingProcess->TenderSubmissionDeadlinePeriod, 'EndDate', 'string');
287
+            $resultEntries['deadLineEndTime'] = $this->existNodo($tenderingProcess->TenderSubmissionDeadlinePeriod, 'EndTime', 'string');
288
+            $resultEntries['documentAvailablePeriod_EndDate'] = $this->existNodo($tenderingProcess->DocumentAvailabilityPeriod, 'EndDate', 'string');
289
+            $resultEntries['documentAvailablePeriod_EndTime'] = $this->existNodo($tenderingProcess->DocumentAvailabilityPeriod, 'EndTime', 'string');
290
+        }
291
+        $resultFinal = $this->array_remove_empty($resultEntries);
292
+        return $resultFinal;
293
+    }
294
+
295
+    private function nodoLegalDoc($xml)
296
+    {
297
+        $resultEntries = array();
298
+        $legalDocumentReference = $xml->ContractFolderStatus->LegalDocumentReference;
299
+
300
+        if (isset($legalDocumentReference)) {
301
+
302
+            for ($i = 0; $i < count($legalDocumentReference); $i++) {
303
+                $resultEntries[$i]['id'] = $this->existNodo($legalDocumentReference[$i], 'ID', 'string');
304
+                $resultEntries[$i]['attachment'] = $this->existNodo($legalDocumentReference[$i]->Attachment->ExternalReference, 'URI', 'string');
305
+                $resultEntries[$i]['documentHash'] = $this->existNodo($legalDocumentReference[$i]->Attachment->ExternalReference, 'DocumentHash', 'string');
306
+            }
307
+
308
+        }
309
+        $resultFinal = $this->array_remove_empty($resultEntries);
310
+        return $resultFinal;
311
+    }
312
+
313
+    private function nodoTechnicalDocumentReference($xml)
314
+    {
315
+        $resultEntries = array();
316
+        $technicalDocumentReference = $xml->ContractFolderStatus->TechnicalDocumentReference;
317
+
318
+        if (isset($technicalDocumentReference)) {
319
+
320
+            for ($i = 0; $i < count($technicalDocumentReference); $i++) {
321
+                $resultEntries[$i]['id'] = $this->existNodo($technicalDocumentReference[$i], 'ID', 'string');
322
+                $resultEntries[$i]['attachment'] = $this->existNodo($technicalDocumentReference[$i]->Attachment->ExternalReference, 'URI', 'string');
323
+                $resultEntries[$i]['documentHash'] = $this->existNodo($technicalDocumentReference[$i]->Attachment->ExternalReference, 'DocumentHash', 'string');
324
+            }
325
+
326
+        }
327
+        $resultFinal = $this->array_remove_empty($resultEntries);
328
+        return $resultFinal;
329
+    }
330
+
331
+    private function nodoAdditionalDocumentReference($xml)
332
+    {
333
+        $resultEntries = array();
334
+        $additionalDocumentReference = $xml->ContractFolderStatus->AdditionalDocumentReference;
335
+
336
+        if (isset($additionalDocumentReference)) {
337
+
338
+            for ($i = 0; $i < count($additionalDocumentReference); $i++) {
339
+                $resultEntries[$i]['id'] = $this->existNodo($additionalDocumentReference[$i], 'ID', 'string');
340
+                $resultEntries[$i]['attachment'] = $this->existNodo($additionalDocumentReference[$i]->Attachment->ExternalReference, 'URI', 'string');
341
+                $resultEntries[$i]['documentHash'] = $this->existNodo($additionalDocumentReference[$i]->Attachment->ExternalReference, 'DocumentHash', 'string');
342
+            }
343
+
344
+        }
345
+        $resultFinal = $this->array_remove_empty($resultEntries);
346
+        return $resultFinal;
347
+    }
348
+
349
+    private function nodoValidNoticeInfo($xml)
350
+    {
351
+        $resultEntries = array();
352
+        $validNoticeInfo = $xml->ContractFolderStatus->ValidNoticeInfo;
353
+
354
+        if (isset($validNoticeInfo)) {
355
+            for ($i = 0; $i < count($validNoticeInfo); $i++) {
356
+                $resultEntries[$i]['NoticeTypeCode'] = $this->existNodo($validNoticeInfo[$i], 'NoticeTypeCode', 'string');
357
+                $resultEntries[$i]['PublicationMediaName'] = $this->existNodo($validNoticeInfo[$i]->AdditionalPublicationStatus, 'PublicationMediaName', 'string');
358
+                $resultEntries[$i]['IssueDate'] = $this->existNodo($validNoticeInfo[$i]->AdditionalPublicationStatus->AdditionalPublicationDocumentReference, 'IssueDate', 'string');
359
+            }
360
+        }
361
+        $resultFinal = $this->array_remove_empty($resultEntries);
362
+        return $resultFinal;
363
+    }
364
+
365
+    private function nodoGeneralDocuments($xml)
366
+    {
367
+        $resultEntries = array();
368
+        $generalDocument = $xml->ContractFolderStatus->GeneralDocument->GeneralDocumentDocumentReference;
369
+
370
+        if (isset($generalDocument)) {
371
+
372
+            for ($i = 0; $i < count($generalDocument); $i++) {
373
+                $resultEntries[$i]['id'] = $this->existNodo($generalDocument[$i], 'ID', 'string');
374
+                $resultEntries[$i]['attachment'] = $this->existNodo($generalDocument[$i]->Attachment->ExternalReference, 'URI', 'string');
375
+                $resultEntries[$i]['documentHash'] = $this->existNodo($generalDocument[$i]->Attachment->ExternalReference, 'DocumentHash', 'string');
376
+            }
377
+
378
+        }
379
+        $resultFinal = $this->array_remove_empty($resultEntries);
380
+        return $resultFinal;
381
+    }
382
+
383
+    private function existNodo($nodo, $nodoHijo, $tipo)
384
+    {
385
+
386
+        if (isset($nodo) && @count($nodo) > 0) {
387
+            return $this->switchTipo($tipo, $nodo->{$nodoHijo});
388
+        } else {
389
+            return "";
390
+        }
391
+    }
392
+
393
+    private function switchTipo($tipo, $nodo)
394
+    {
395
+        switch ($tipo) {
396
+            case 'string':
397
+                return (string) $nodo;
398
+                break;
399
+            case 'int':
400
+                return (int) $nodo;
401
+                break;
402
+            case 'array':
403
+                return (array) $nodo;
404
+                break;
405
+        }
406
+    }
407
+
408
+    public function RecurseXML($xml, $parent = "")
409
+    {
410
+        $child_count = 0;
411
+        $result = array();
412
+        foreach ($xml as $key => $value) {
413
+            $child_count++;
414
+            if ($this->RecurseXML($value, $parent . "." . $key) == 0) // no childern, aka "leaf node"
415
+            {
416
+                //print($parent . "." . (string) $key . " = " . (string) $value . "<BR>\n");
417
+
418
+            }
419
+        }
420
+        return $child_count;
421
+    }
422
+
423
+    public function array_remove_empty($haystack)
424
+    {
425
+        foreach ($haystack as $key => $value) {
426
+            if (is_array($value)) {
427
+                $haystack[$key] = $this->array_remove_empty($haystack[$key]);
428
+            }
429
+
430
+            if (empty($haystack[$key])) {
431
+                unset($haystack[$key]);
432
+            }
433
+        }
434
+
435
+        return $haystack;
436
+    }
437
+
438
+	/* public function xml2array($xml)
439
+    {
440
+        $arr = array();
441
+
442
+        foreach ($xml->getNamespaces() + array(null) as $prefix => $namespace) {
443
+            foreach ($xml->attributes($namespace) as $key => $value) {
444
+                // Add prefixes to prefixed attributes
445
+                if (is_string($prefix)) {
446
+                    $key = $prefix . '.' . $key;
447
+                }
448
+                $arr['@attributes'][$key] = (string) $value;
449
+            }
450
+        }
451
+
452
+        foreach ($xml as $name => $element) {
453
+            $value = $element->children() ? $this->xml2array($element) : trim($element);
454
+            if ($value) {
455
+                if (!isset($arr[$name])) {
456
+                    $arr[$name] = $value;
457
+                } else {
458
+                    foreach ((array) $value as $k => $v) {
459
+                        if (is_numeric($k)) {
460
+                            $arr[$name][] = $v;
461
+                        } else {
462
+                            $arr[$name][$k] = array_merge(
463
+                                (array) $arr[$name][$k],
464
+                                (array) $v
465
+                            );
466
+                        }
467
+                    }
468
+                }
469
+            }
470
+        }
471
+
472
+        if ($content = trim((string) $xml)) {
473
+            $arr[] = $content;
474
+        }
475
+
476
+        return $arr;
477
+    } 
478
+	$reader = new \XMLReader;
479
+            $reader->open($file); // where $path is the file path to the xml file
480
+
481
+            // using a dirty trick to skip most of the xml that is irrelevant where $nodeName is the node im looking for
482
+            // then in the next while loop i skip to the next node
483
+            $data = array();
484
+            while ($reader->read() && $reader->name !== "data");
485
+            while ($reader->name === "data") {
486
+                $doc = new \DOMDocument;
487
+                $dom = $doc->importNode($reader->expand(), true);
488
+                $data = $this->processDom($dom);
489
+                $reader->next($dom->localName);
490
+            }
491
+
492
+	public function processDom(\DOMNode $node)
493
+    {
494
+        $data = [];
495
+        /** @var \DomNode $childNode 
496
+        foreach ($node->childNodes as $childNode) {
497
+            // child nodes include of a lot of #text nodes which are irrelevant for me, so i just skip them
498
+            if ($childNode->nodeName === '#text') {
499
+                continue;
500
+            }
501
+            $childData = $this->processDom($childNode);
502
+            if ($childData === null || $childData === []) {
503
+                $data[$childNode->localName] = $childNode->nodeValue;
504
+            } else {
505
+                $data[$childNode->localName] = $childData;
506
+            }
507
+        }
508
+        return $data;
509
+    }
510
+	
511
+	*/
512
+
513
+}
514
+
515
+/* End of file ParserFile.php */
516
+/* Location: ./application/controllers/ParserFile.php */