Kasutaja tarvikud

Lehe tööriistad



et:xmlcore

Erinevused

Siin näed erinevusi valitud versiooni ja hetkel kehtiva lehekülje vahel.

Lõlita võrdlemise vaatele

Both sides previous revision Previous revision
Next revision Both sides next revision
et:xmlcore [2015/08/24 18:20]
ott
et:xmlcore [2015/08/24 18:33]
ott
Rida 109: Rida 109:
  
 ====PHP näide==== ====PHP näide====
 +===Väljund===
 <code php> <code php>
 +$url = '​https://​directo.gate.ee/​xmlcore/​demo_ee/​xmlcore.asp?​get=1&​what=item&​key=20DAF3F822B782AF12D1198C23F45604';​
  
-$xmldata ​= <<<​XML +$ch curl_init();​ 
-<?xml version="​1.0"​ encoding="​UTF-8"?>​+curl_setopt($ch,​ CURLOPT_HEADER,​ 0); 
 +curl_setopt($ch,​ CURLOPT_RETURNTRANSFER,​ true); 
 +curl_setopt($ch,​ CURLOPT_URL,​ $url ); 
 +curl_setopt($ch,​ CURLOPT_POST,​ 0); 
 + 
 +$result = curl_exec($ch);​ 
 + 
 +header('​Content-Type:​ text/html; charset=utf-8'​);​ 
 + 
 +print '<textarea cols=80 rows=10>'​ . $result . '</​textarea>';​ 
 + 
 +$data = new SimpleXMLElement($result);​ 
 + 
 +print '<pre>';​ 
 + 
 +foreach ($data->​items->​item as $item) { 
 + print $item['​Code'​] . chr(9) .  '<​b>'​ . $item['​Name'​] . '</​b>'​ . chr(9) .  $item['​Class'​] . '<​br>';​ 
 + foreach ($item->​datafields->​data as $df ) { 
 + print chr(9) . $df['​code'​] . ':'​ . $df['​content'​] . '<​br>';​ 
 +
 +
 +</​code>​ 
 + 
 + 
 +===Sisend=== 
 +<code php> 
 + 
 +$xmldata = '<'​.'​?xml version="​1.0"​ encoding="​UTF-8"?>​
 <invoice AppKey="​1234567879012345678790"​ InvoiceNr="​123" ​ <invoice AppKey="​1234567879012345678790"​ InvoiceNr="​123" ​
  InvoiceDate="​2015-06-07"​ CustomerCode="​CUST001">​  InvoiceDate="​2015-06-07"​ CustomerCode="​CUST001">​
Rida 119: Rida 148:
       <line ProductID="​FREESAMPLE"​ Quantity="​1"​ UnitPriceWoVAT="​0.00"/>​       <line ProductID="​FREESAMPLE"​ Quantity="​1"​ UnitPriceWoVAT="​0.00"/>​
     </​lines>​     </​lines>​
-  ​</​invoice>​ +</​invoice>​'; 
-XML;+
 $url = '​https://​directo.gate.ee/​xmlcore/​this_is_the_worlds_greatest_company/​xmlcore.asp';​ $url = '​https://​directo.gate.ee/​xmlcore/​this_is_the_worlds_greatest_company/​xmlcore.asp';​
  
Rida 136: Rida 165:
 curl_close($ch);​ curl_close($ch);​
 </​code>​ </​code>​
- 
et/xmlcore.txt · Viimati muutnud: 2024/04/16 09:19 persoon toomas