Login to website

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Login to website

Post by edk »

Similar to the SendInvoices method.
You just have to:
1. change cUrl

Code: Select all

Local cUrl := "https://mydata-dev.azure-api.net/RequestInvoices"
2. add to cUrl a query for:
a) mark (Last unique registration number received)
b) nextPartitionKey (If the continuation of the token is returned to the previous call, this field must be filled in to continue the results)
c) nextRowKey (If the continuation of the token is returned to the previous call, this field must be filled in to continue the results)

Code: Select all

Local cQuery := "mark=" + {mark} + "&nextPartitionKey=" + {nextPartitionKey} + "&nextRowKey=" + {nextRowKey}
cUrl := cUrl + "?" + cQuery

3. Change the call from POST to GET

Code: Select all

ohttp:Open( "GET", cUrl , .F. )
4. send empty body

Code: Select all

//send request
ohttp:Send()

If there are no errors, you should receive an XML response similar to this:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<requestedInvoicesDoc xmlns="http://www.aade.gr/myDATA/invoice/v1.0"
  xsi:schemaLocation="http://www.aade.gr/myDATA/invoice/v1.0 schema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <continuationToken>
    <nextPartitionKey>string</nextPartitionKey>
    <nextRowKey>string</nextRowKey>
  </continuationToken>
  <invoicesDoc>
    <invoice>
      <uid>string</uid>
      <mark>string</mark>
      <issuer>
        <vatNumber>string</vatNumber>
        <country>CZ</country>
        <name>string</name>
        <address>
          <street>string</street>
          <number>string</number>
          <postalCode>string</postalCode>
          <city>string</city>
        </address>
      </issuer>
      <counterpart>
        <vatNumber>string</vatNumber>
        <country>LS</country>
        <name>string</name>
        <address>
          <street>string</street>
          <number>string</number>
          <postalCode>string</postalCode>
          <city>string</city>
        </address>
      </counterpart>
      <invoiceHeader>
        <branch>-569</branch>
        <series>string</series>
        <aa>-3745</aa>
        <issueDate>1999-04-24</issueDate>
        <invoiceType>8.1</invoiceType>
        <vatPaymentSuspension>false</vatPaymentSuspension>
        <currency>MXN</currency>
        <exchangeRate>3312920.23</exchangeRate>
        <correlatedInvoices>string</correlatedInvoices>
        <selfPricing>1</selfPricing>
        <dispatchDate>1981-09-26</dispatchDate>
        <dispatchTime>09:08:52.53</dispatchTime>
        <vehicleNumber>string</vehicleNumber>
        <movePurpose>string</movePurpose>
      </invoiceHeader>
      <invoiceDetails>
        <lineNumber>6445</lineNumber>
        <quantity>2028410.2349058</quantity>
        <measurementUnit>1</measurementUnit>
        <invoiceDetailType>2</invoiceDetailType>
        <netValue>160230.23491</netValue>
        <vatCategory>5</vatCategory>
        <vatExemptionCategory>11</vatExemptionCategory>
        <dienergia>
          <applicationId>string</applicationId>
          <applicationDate>2009-07-05</applicationDate>
          <shipId>string</shipId>
        </dienergia>
        <discountOption>0</discountOption>
        <withheldAmount>7347210.23491</withheldAmount>
        <withheldPercentCategory>1</withheldPercentCategory>
        <stampDutyPercentCategory>1</stampDutyPercentCategory>
        <feesAmount>4283990.23491</feesAmount>
        <feesPercentCategory>2</feesPercentCategory>
        <otherTaxesPercentCategory>7</otherTaxesPercentCategory>
        <otherTaxesAmount>2993750.23491</otherTaxesAmount>
        <deductionsPercentage>54.69</deductionsPercentage>
        <incomeClassification>
          <classificationType>207</classificationType>
          <classificationCategory>1</classificationCategory>
          <amount>97890.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>210</classificationType>
          <classificationCategory>4</classificationCategory>
          <amount>309640.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>207</classificationType>
          <classificationCategory>2</classificationCategory>
          <amount>4918450.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>203</classificationType>
          <classificationCategory>4</classificationCategory>
          <amount>3786770.23491</amount>
        </incomeClassification>
      </invoiceDetails>
      <invoiceDetails>
        <lineNumber>9498</lineNumber>
        <quantity>2881880.2349058</quantity>
        <measurementUnit>2</measurementUnit>
        <invoiceDetailType>2</invoiceDetailType>
        <netValue>4840840.23491</netValue>
        <vatCategory>3</vatCategory>
        <vatExemptionCategory>3</vatExemptionCategory>
        <dienergia>
          <applicationId>string</applicationId>
          <applicationDate>2008-12-17</applicationDate>
          <shipId>string</shipId>
        </dienergia>
        <discountOption>true</discountOption>
        <withheldAmount>812600.23491</withheldAmount>
        <withheldPercentCategory>5</withheldPercentCategory>
        <stampDutyPercentCategory>2</stampDutyPercentCategory>
        <feesAmount>6671270.23491</feesAmount>
        <feesPercentCategory>7</feesPercentCategory>
        <otherTaxesPercentCategory>8</otherTaxesPercentCategory>
        <otherTaxesAmount>9395170.23491</otherTaxesAmount>
        <deductionsPercentage>33.76</deductionsPercentage>
        <incomeClassification>
          <classificationType>209</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>9808520.23491</amount>
        </incomeClassification>
      </invoiceDetails>
      <invoiceDetails>
        <lineNumber>8453</lineNumber>
        <quantity>3325610.2349058</quantity>
        <measurementUnit>3</measurementUnit>
        <invoiceDetailType>2</invoiceDetailType>
        <netValue>3657720.23491</netValue>
        <vatCategory>2</vatCategory>
        <vatExemptionCategory>4</vatExemptionCategory>
        <dienergia>
          <applicationId>string</applicationId>
          <applicationDate>1985-05-10</applicationDate>
          <shipId>string</shipId>
        </dienergia>
        <discountOption>0</discountOption>
        <withheldAmount>1092910.23491</withheldAmount>
        <withheldPercentCategory>1</withheldPercentCategory>
        <stampDutyPercentCategory>1</stampDutyPercentCategory>
        <feesAmount>3284320.23491</feesAmount>
        <feesPercentCategory>4</feesPercentCategory>
        <otherTaxesPercentCategory>7</otherTaxesPercentCategory>
        <otherTaxesAmount>3416910.23491</otherTaxesAmount>
        <deductionsPercentage>94.69</deductionsPercentage>
        <incomeClassification>
          <classificationType>206</classificationType>
          <classificationCategory>2</classificationCategory>
          <amount>6514000.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>202</classificationType>
          <classificationCategory>4</classificationCategory>
          <amount>6494280.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>204</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>9341400.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>202</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>6564580.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>210</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>2022420.23491</amount>
        </incomeClassification>
      </invoiceDetails>
      <invoiceSummary>
        <totalNetValue>9809460.23491</totalNetValue>
        <totalVatAmount>1011700.23491</totalVatAmount>
        <totalWithheldAmount>1082400.23491</totalWithheldAmount>
        <totalFeesAmount>7293520.23491</totalFeesAmount>
        <totalStampDutyAmount>5044110.23491</totalStampDutyAmount>
        <totalOtherTaxesAmount>1493850.23491</totalOtherTaxesAmount>
        <totalDeductionsAmount>4116330.23491</totalDeductionsAmount>
        <totalGrossValue>9936610.23491</totalGrossValue>
        <incomeClassification>
          <classificationType>205</classificationType>
          <classificationCategory>1</classificationCategory>
          <amount>5742490.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>203</classificationType>
          <classificationCategory>2</classificationCategory>
          <amount>4278070.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>206</classificationType>
          <classificationCategory>4</classificationCategory>
          <amount>1439840.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>209</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>5224060.23491</amount>
        </incomeClassification>
      </invoiceSummary>
    </invoice>
    <invoice>
      <uid>string</uid>
      <mark>string</mark>
      <issuer>
        <vatNumber>string</vatNumber>
        <country>CH</country>
        <name>string</name>
        <address>
          <street>string</street>
          <number>string</number>
          <postalCode>string</postalCode>
          <city>string</city>
        </address>
      </issuer>
      <counterpart>
        <vatNumber>string</vatNumber>
        <country>MC</country>
        <name>string</name>
        <address>
          <street>string</street>
          <number>string</number>
          <postalCode>string</postalCode>
          <city>string</city>
        </address>
      </counterpart>
      <invoiceHeader>
        <branch>-992</branch>
        <series>string</series>
        <aa>3169</aa>
        <issueDate>1993-07-27</issueDate>
        <invoiceType>3.1</invoiceType>
        <vatPaymentSuspension>false</vatPaymentSuspension>
        <currency>BDT</currency>
        <exchangeRate>9589470.23</exchangeRate>
        <correlatedInvoices>string</correlatedInvoices>
        <selfPricing>true</selfPricing>
        <dispatchDate>2010-08-26</dispatchDate>
        <dispatchTime>06:53:58.51</dispatchTime>
        <vehicleNumber>string</vehicleNumber>
        <movePurpose>string</movePurpose>
      </invoiceHeader>
      <invoiceDetails>
        <lineNumber>8226</lineNumber>
        <quantity>4487720.2349058</quantity>
        <measurementUnit>2</measurementUnit>
        <invoiceDetailType>2</invoiceDetailType>
        <netValue>4499740.23491</netValue>
        <vatCategory>2</vatCategory>
        <vatExemptionCategory>17</vatExemptionCategory>
        <dienergia>
          <applicationId>string</applicationId>
          <applicationDate>2003-11-08</applicationDate>
          <shipId>string</shipId>
        </dienergia>
        <discountOption>true</discountOption>
        <withheldAmount>7372060.23491</withheldAmount>
        <withheldPercentCategory>5</withheldPercentCategory>
        <stampDutyPercentCategory>2</stampDutyPercentCategory>
        <feesAmount>477860.23491</feesAmount>
        <feesPercentCategory>6</feesPercentCategory>
        <otherTaxesPercentCategory>6</otherTaxesPercentCategory>
        <otherTaxesAmount>374800.23491</otherTaxesAmount>
        <deductionsPercentage>45.21</deductionsPercentage>
        <incomeClassification>
          <classificationType>209</classificationType>
          <classificationCategory>1</classificationCategory>
          <amount>7007970.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>205</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>29750.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>202</classificationType>
          <classificationCategory>2</classificationCategory>
          <amount>1153840.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>204</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>8769490.23491</amount>
        </incomeClassification>
      </invoiceDetails>
      <invoiceDetails>
        <lineNumber>8934</lineNumber>
        <quantity>4063830.2349058</quantity>
        <measurementUnit>2</measurementUnit>
        <invoiceDetailType>1</invoiceDetailType>
        <netValue>5116470.23491</netValue>
        <vatCategory>2</vatCategory>
        <vatExemptionCategory>14</vatExemptionCategory>
        <dienergia>
          <applicationId>string</applicationId>
          <applicationDate>1971-05-09</applicationDate>
          <shipId>string</shipId>
        </dienergia>
        <discountOption>0</discountOption>
        <withheldAmount>1096810.23491</withheldAmount>
        <withheldPercentCategory>10</withheldPercentCategory>
        <stampDutyPercentCategory>1</stampDutyPercentCategory>
        <feesAmount>4683950.23491</feesAmount>
        <feesPercentCategory>7</feesPercentCategory>
        <otherTaxesPercentCategory>5</otherTaxesPercentCategory>
        <otherTaxesAmount>9038500.23491</otherTaxesAmount>
        <deductionsPercentage>59.15</deductionsPercentage>
        <incomeClassification>
          <classificationType>201</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>119520.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>207</classificationType>
          <classificationCategory>1</classificationCategory>
          <amount>7092000.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>208</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>5009050.23491</amount>
        </incomeClassification>
      </invoiceDetails>
      <invoiceDetails>
        <lineNumber>1995</lineNumber>
        <quantity>9522900.2349058</quantity>
        <measurementUnit>3</measurementUnit>
        <invoiceDetailType>2</invoiceDetailType>
        <netValue>3219150.23491</netValue>
        <vatCategory>4</vatCategory>
        <vatExemptionCategory>20</vatExemptionCategory>
        <dienergia>
          <applicationId>string</applicationId>
          <applicationDate>1988-11-21</applicationDate>
          <shipId>string</shipId>
        </dienergia>
        <discountOption>true</discountOption>
        <withheldAmount>8125620.23491</withheldAmount>
        <withheldPercentCategory>9</withheldPercentCategory>
        <stampDutyPercentCategory>1</stampDutyPercentCategory>
        <feesAmount>138800.23491</feesAmount>
        <feesPercentCategory>4</feesPercentCategory>
        <otherTaxesPercentCategory>3</otherTaxesPercentCategory>
        <otherTaxesAmount>6842370.23491</otherTaxesAmount>
        <deductionsPercentage>94.83</deductionsPercentage>
        <incomeClassification>
          <classificationType>209</classificationType>
          <classificationCategory>4</classificationCategory>
          <amount>3401200.23491</amount>
        </incomeClassification>
      </invoiceDetails>
      <invoiceDetails>
        <lineNumber>3198</lineNumber>
        <quantity>9504330.2349058</quantity>
        <measurementUnit>2</measurementUnit>
        <invoiceDetailType>1</invoiceDetailType>
        <netValue>4034070.23491</netValue>
        <vatCategory>3</vatCategory>
        <vatExemptionCategory>22</vatExemptionCategory>
        <dienergia>
          <applicationId>string</applicationId>
          <applicationDate>1990-03-21</applicationDate>
          <shipId>string</shipId>
        </dienergia>
        <discountOption>false</discountOption>
        <withheldAmount>2396460.23491</withheldAmount>
        <withheldPercentCategory>8</withheldPercentCategory>
        <stampDutyPercentCategory>3</stampDutyPercentCategory>
        <feesAmount>8214250.23491</feesAmount>
        <feesPercentCategory>5</feesPercentCategory>
        <otherTaxesPercentCategory>5</otherTaxesPercentCategory>
        <otherTaxesAmount>2269810.23491</otherTaxesAmount>
        <deductionsPercentage>72.97</deductionsPercentage>
        <incomeClassification>
          <classificationType>207</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>8576400.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>208</classificationType>
          <classificationCategory>2</classificationCategory>
          <amount>450830.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>207</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>6840340.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>203</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>9211860.23491</amount>
        </incomeClassification>
      </invoiceDetails>
      <invoiceSummary>
        <totalNetValue>1774740.23491</totalNetValue>
        <totalVatAmount>5141630.23491</totalVatAmount>
        <totalWithheldAmount>5961950.23491</totalWithheldAmount>
        <totalFeesAmount>1851820.23491</totalFeesAmount>
        <totalStampDutyAmount>1009130.23491</totalStampDutyAmount>
        <totalOtherTaxesAmount>8423590.23491</totalOtherTaxesAmount>
        <totalDeductionsAmount>5353790.23491</totalDeductionsAmount>
        <totalGrossValue>1547620.23491</totalGrossValue>
        <incomeClassification>
          <classificationType>206</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>3991720.23491</amount>
        </incomeClassification>
      </invoiceSummary>
    </invoice>
    <invoice>
      <uid>string</uid>
      <mark>string</mark>
      <issuer>
        <vatNumber>string</vatNumber>
        <country>TZ</country>
        <name>string</name>
        <address>
          <street>string</street>
          <number>string</number>
          <postalCode>string</postalCode>
          <city>string</city>
        </address>
      </issuer>
      <counterpart>
        <vatNumber>string</vatNumber>
        <country>AN</country>
        <name>string</name>
        <address>
          <street>string</street>
          <number>string</number>
          <postalCode>string</postalCode>
          <city>string</city>
        </address>
      </counterpart>
      <invoiceHeader>
        <branch>3533</branch>
        <series>string</series>
        <aa>2073</aa>
        <issueDate>1973-12-13</issueDate>
        <invoiceType>14.4</invoiceType>
        <vatPaymentSuspension>1</vatPaymentSuspension>
        <currency>THB</currency>
        <exchangeRate>7903660.23</exchangeRate>
        <correlatedInvoices>string</correlatedInvoices>
        <correlatedInvoices>string</correlatedInvoices>
        <correlatedInvoices>string</correlatedInvoices>
        <correlatedInvoices>string</correlatedInvoices>
        <selfPricing>0</selfPricing>
        <dispatchDate>2015-07-24</dispatchDate>
        <dispatchTime>16:35:19.24</dispatchTime>
        <vehicleNumber>string</vehicleNumber>
        <movePurpose>string</movePurpose>
      </invoiceHeader>
      <invoiceDetails>
        <lineNumber>7243</lineNumber>
        <quantity>1975700.2349058</quantity>
        <measurementUnit>2</measurementUnit>
        <invoiceDetailType>2</invoiceDetailType>
        <netValue>5052760.23491</netValue>
        <vatCategory>4</vatCategory>
        <vatExemptionCategory>3</vatExemptionCategory>
        <dienergia>
          <applicationId>string</applicationId>
          <applicationDate>2003-09-18</applicationDate>
          <shipId>string</shipId>
        </dienergia>
        <discountOption>true</discountOption>
        <withheldAmount>4315320.23491</withheldAmount>
        <withheldPercentCategory>9</withheldPercentCategory>
        <stampDutyPercentCategory>2</stampDutyPercentCategory>
        <feesAmount>8158030.23491</feesAmount>
        <feesPercentCategory>2</feesPercentCategory>
        <otherTaxesPercentCategory>8</otherTaxesPercentCategory>
        <otherTaxesAmount>1835500.23491</otherTaxesAmount>
        <deductionsPercentage>26.67</deductionsPercentage>
        <incomeClassification>
          <classificationType>205</classificationType>
          <classificationCategory>3</classificationCategory>
          <amount>7392870.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>204</classificationType>
          <classificationCategory>1</classificationCategory>
          <amount>1794450.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>202</classificationType>
          <classificationCategory>1</classificationCategory>
          <amount>4858200.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>204</classificationType>
          <classificationCategory>2</classificationCategory>
          <amount>7525280.23491</amount>
        </incomeClassification>
        <incomeClassification>
          <classificationType>203</classificationType>
          <classificationCategory>2</classificationCategory>
          <amount>9217930.23491</amount>
        </incomeClassification>
      </invoiceDetails>
      <invoiceSummary>
        <totalNetValue>833200.23491</totalNetValue>
        <totalVatAmount>7815010.23491</totalVatAmount>
        <totalWithheldAmount>5441290.23491</totalWithheldAmount>
        <totalFeesAmount>1188270.23491</totalFeesAmount>
        <totalStampDutyAmount>2792120.23491</totalStampDutyAmount>
        <totalOtherTaxesAmount>8489070.23491</totalOtherTaxesAmount>
        <totalDeductionsAmount>9363580.23491</totalDeductionsAmount>
        <totalGrossValue>1653830.23491</totalGrossValue>
        <incomeClassification>
          <classificationType>208</classificationType>
          <classificationCategory>2</classificationCategory>
          <amount>7600740.23491</amount>
        </incomeClassification>
      </invoiceSummary>
    </invoice>
  </invoicesDoc>
</requestedInvoicesDoc>
User avatar
tomtagaris
Posts: 107
Joined: Tue Aug 23, 2016 2:43 pm

Re: Login to website

Post by tomtagaris »

thank you very much edk
i will try it when the site is in integration because it has problems
your help is valuable
Thanks for everything
TomTagaris
User avatar
tomtagaris
Posts: 107
Joined: Tue Aug 23, 2016 2:43 pm

Re: Login to website

Post by tomtagaris »

finally adk the program worked well
I send the archive .xml and the server responds by sending me an archive .xml
extract data from the .xml with the at() function but i want to ask if there is any other way to extract the data i want from the archive xml

<?xml version="1.0" encoding="utf-8"?>
<ResponseDoc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<response>
<entitylineNumber>1</entitylineNumber>
<statusCode>Success</statusCode>
<entityUid>8B5F90485B444AC25259C053646A3F098C6965F9</entityUid>
<entityMark>1000000221392</entityMark>
</response>
</ResponseDoc>
thanks
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Login to website

Post by edk »

tomtagaris wrote: Tue Sep 17, 2019 9:22 am finally adk the program worked well
I send the archive .xml and the server responds by sending me an archive .xml
extract data from the .xml with the at() function but i want to ask if there is any other way to extract the data i want from the archive xml

<?xml version="1.0" encoding="utf-8"?>
<ResponseDoc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<response>
<entitylineNumber>1</entitylineNumber>
<statusCode>Success</statusCode>
<entityUid>8B5F90485B444AC25259C053646A3F098C6965F9</entityUid>
<entityMark>1000000221392</entityMark>
</response>
</ResponseDoc>
thanks
For example, you can use Harbour's minixml wrapper (viewtopic.php?f=5&t=2120) or xhb to handle XML.
For a simple XML structure, you can use this function:

Code: Select all

Function GetFromXML ( cXml, cTag )
Local cRet := "", nPosOpen := At( "<" + Upper( cTag ) + ">", Upper( cXml ) ), nPosClose := At( "</" + Upper( cTag ) + ">", Upper( cXml ) )

If nPosOpen > 0 .AND. nPosClose > nPosOpen 
	cRet := SubStr( cXml, nPosOpen + Len( cTag ) + 2, nPosClose - nPosOpen - Len( cTag ) - 2 )
EndIf

RETURN StrTran( cRet, Chr( 10 ), CRLF ) 
ex. cUid := GetFromXML ( cXml, "entityuid" )
PeteWG
Posts: 176
Joined: Sun Mar 21, 2010 5:45 pm

Re: Login to website

Post by PeteWG »

tomtagaris wrote: Tue Sep 17, 2019 9:22 am finally adk the program worked well
I send the archive .xml and the server responds by sending me an archive .xml
Hi Tom
would you mind to post here your source code?
It will probably be useful as a reference for other members of this group,
in case someone would trying to make something similar in the future.
(Not to mention that it might lead to improvements of this code itself.)

regards,
Pete
PeteWG
Posts: 176
Joined: Sun Mar 21, 2010 5:45 pm

Re: Login to website

Post by PeteWG »

Addendum:
bellow is code to extract data (nodes) from an .xml file using harbour's hbmxml library.

Code: Select all

#include "hbmxml.ch"
/*
   compile: hbmk2 test.prg hbmxml.hbc
   run    : test2 resp.xml
*/
PROCEDURE Main( xmlName, firstNode  )
   LOCAL body, xmlBuffer, nLen
   LOCAL aNodes := {}

   IF hb_fileExists( xmlName )
      xmlBuffer := hb_memoRead( xmlName )
      body := mxmlLoadString( nil, xmlBuffer, MXML_OPAQUE_CALLBACK )
      IF ! empty( firstNode )
         body := mxmlFindElement( body, body, firstNode, nil, nil, MXML_DESCEND )
      ENDIF
      aNodes := iterateXml( body, , aNodes )
   ENDIF
   
   IF Len( aNodes ) > 0
      nLen := 0
      AEval( aNodes, { |e| nLen := Max( Len( e[1]), nLen ) } )
      ? "Total nodes: ", hb_ntos( Len(aNodes) )
      ? "--------------------------------------------"
      AEval( aNodes, { |e| Qout( PadR( e[1], nLen ), " : ", e[2] ) } )
      ?
   ENDIF

   RETURN

FUNCTION iterateXml( node, level, aRet )
   STATIC aKey := {}
   LOCAL element
   LOCAL opaque
   LOCAL child
   LOCAL cKey

   IF level = NIL
    level := 0
   ELSE
    ++level
   ENDIF

   WHILE node != nil
      element := mxmlGetElement( node )
      IF ! empty( element )
         AAdd( aKey, element )
      ENDIF
      IF mxmlGetType( node ) = MXML_OPAQUE
         opaque := mxmlGetOpaque( node )
         IF ! empty( opaque )
            cKey := Atail( aKey )
            AAdd( aRet, { cKey , opaque } )
         ENDIF
      ENDIF
      child := mxmlGetFirstChild( node )
      IF child != nil
      iterateXml( child, @level, aRet )
      ENDIF
      node := mxmlGetNextSibling( node )
   ENDDO
   RETURN aRet
save above code as test.prg and compile
save your response data as a file resp.xml
run it : test resp.xml
see the output on screen

regards,
Pete
User avatar
tomtagaris
Posts: 107
Joined: Tue Aug 23, 2016 2:43 pm

Re: Login to website

Post by tomtagaris »

Hi adk
about function GetFromXML have problem base/ 1066
  Hi PeteWG
the code if i understood it well is on page 1 of the post posted by adk
how to combile test.prg from hmg with library hbmxml.hbc
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Login to website

Post by edk »

tomtagaris wrote: Wed Sep 18, 2019 8:58 am Hi adk
about function GetFromXML have problem base/ 1066
Where?
It is a condition: If nPosOpen> 0 .AND. nPosClose> nPosOpen ?
Rather, it is not possible for the variables nPosOpen and nPosClose to not have numeric values, so the condition must be logical :?

I tested the function with your xml response, it works fine :arrow:

Code: Select all

#include "hmg.ch"

Function Main ()

cXml := '<?xml version="1.0" encoding="utf-8"?>' + ;
	'<ResponseDoc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' + ;
	'<response>' + ;
	'<entitylineNumber>1</entitylineNumber>' + ;
	'<statusCode>Success</statusCode>' + ;
	'<entityUid>8B5F90485B444AC25259C053646A3F098C6965F9</entityUid>' + ;
	'<entityMark>1000000221392</entityMark>' + ;
	'</response>' + ;
	'</ResponseDoc>'


MsgInfo ('entitylineNumber:' + chr(9) + GetFromXML ( cXml, "entitylineNumber" ) + CRLF + ;
	'statusCode:' + chr(9) + GetFromXML ( cXml, "statusCode" ) + CRLF + ;
	'entityUid:' + chr(9) + GetFromXML ( cXml, "entityUid" ) + CRLF + ;
	'entityMark:' + chr(9) + GetFromXML ( cXml, "entityMark" ) + CRLF + ;
	'WrongNode:' + chr(9) + GetFromXML ( cXml, "WrongNode" ) )


RETURN Nil

************************************************************************
Function GetFromXML ( cXml, cTag )
Local cRet := "", nPosOpen := At( "<" + Upper( cTag ) + ">", Upper( cXml ) ), nPosClose := At( "</" + Upper( cTag ) + ">", Upper( cXml ) )

If nPosOpen > 0 .AND. nPosClose > nPosOpen 
	cRet := SubStr( cXml, nPosOpen + Len( cTag ) + 2, nPosClose - nPosOpen - Len( cTag ) - 2 )
EndIf

RETURN StrTran( cRet, Chr( 10 ), CRLF ) 

User avatar
tomtagaris
Posts: 107
Joined: Tue Aug 23, 2016 2:43 pm

Re: Login to website

Post by tomtagaris »

THAT WORKS GOOD BUT WHEN I SET IN cXml = ohttp:ResponseBody() return error
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Login to website

Post by edk »

tomtagaris wrote: Wed Sep 18, 2019 10:24 am THAT WORKS GOOD BUT WHEN I SET IN cXml = ohttp:ResponseBody() return error
Please, send to me the file tomresp.xml generated by:

Code: Select all

StrFile (ohttp:ResponseBody(), 'tomresp.xml' )
Post Reply