john_gringo
Registered User.
- Local time
- Today, 07:45
- Joined
- Nov 1, 2011
- Messages
- 87
I am new to Access and VBA.
I'm POSTing some data using the bellow code I receive an XML response.
From the following XML response, I need to extract UID and MARK and update table fields. The criteria for the update is <index> number.
<?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>
<index>1</index>
<invoiceUid>BAC9861A68546E5F7D2E7E0AF052E3F443B5174D</invoiceUid>
<invoiceMark>400001851984363</invoiceMark>
<statusCode>Success</statusCode>
</response>
</ResponseDoc>
Any help will be much appreciated
Regards
Jiannis
I'm POSTing some data using the bellow code I receive an XML response.
Code:
Sub POSTreq()
Dim req As New MSXML2.XMLHTTP60
Dim reqURL As String
Dim Db As Database
Dim Rst As Recordset
Dim Tbl As String
Dim restxt As String
Set Db = CurrentDb
Tbl = "SELECT APOST_NUM.ID, APOST_NUM.TOT_VALUE, APOST_NUM.AP_DATE, APOST_NUM.PH_ID, APOST_NUM.PAR_OK, APOST_NUM.CHK_MET, Singular_Data.NAME, Singular_Data.AFM, Singular_Data.STREET, Singular_Data.STRNUMBER, Singular_Data.CITY, Singular_Data.PHONE1 FROM Singular_Data INNER JOIN APOST_NUM ON Singular_Data.NAME = APOST_NUM.PHARMACY WHERE (((APOST_NUM.AP_DATE)>#19/10/2021#));"
Set Rst = Db.OpenRecordset(Tbl, 2)
With Rst
Do While Not .EOF
reqURL = "https://mydata-dev.azure-api.net/SendInvoices"
req.Open "POST", reqURL, False
req.setRequestHeader "aade-user-id", "YahooTest"
req.setRequestHeader "Ocp-Apim-Subscription-Key", "ce9fbb3df4eb4a10ac56b6e8120e773c"
myData = ""
myData = "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>"
myData = myData + "<InvoicesDoc xmlns=""http://www.aade.gr/myDATA/invoice/v1.0"" xsi:schemaLocation=""http://www.aade.gr/myDATA/invoice/v1.0 schema.xsd"" xmlns:icls=""https://www.aade.gr/myDATA/incomeClassificaton/v1.0"" xmlns:ecls=""https://www.aade.gr/myDATA/expensesClassificaton/v1.0"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">"
myData = myData + " <invoice>"
myData = myData + " <issuer>"
myData = myData + " <vatNumber>033600949</vatNumber>"
myData = myData + " <country>GR</country>"
myData = myData + " <branch>0</branch>"
myData = myData + " </issuer>"
myData = myData + " <counterpart>"
myData = myData + " <vatNumber>" & Rst!AFM & "</vatNumber>"
myData = myData + " <country>GR</country>"
myData = myData + " <branch>0</branch>"
myData = myData + " <address>"
myData = myData + " <street>ODOS PELATH</street>"
myData = myData + " <number>11</number>"
myData = myData + " <postalCode>11111</postalCode>"
myData = myData + " <city>PERIOXH PELATH</city>"
myData = myData + " </address>"
myData = myData + " </counterpart>"
myData = myData + " <invoiceHeader>"
myData = myData + " <series>TIM</series>"
myData = myData + " <aa>000152</aa>"
myData = myData + " <issueDate>2020-09-30</issueDate>"
myData = myData + " <invoiceType>1.1</invoiceType>"
myData = myData + " <currency>EUR</currency>"
myData = myData + " </invoiceHeader>"
myData = myData + " <paymentMethods>"
myData = myData + " <paymentMethodDetails>"
myData = myData + " <type>5</type>"
myData = myData + " <amount>31.00</amount>"
myData = myData + " </paymentMethodDetails>"
myData = myData + " </paymentMethods>"
myData = myData + " <invoiceDetails>"
myData = myData + " <lineNumber>10001</lineNumber>"
myData = myData + " <netValue>25.00</netValue>"
myData = myData + " <vatCategory>1</vatCategory>"
myData = myData + " <vatAmount>6.00</vatAmount>"
myData = myData + " <incomeClassification>"
myData = myData + " <icls:classificationType>E3_561_001</icls:classificationType>"
myData = myData + " <icls:classificationCategory>category1_1</icls:classificationCategory>"
myData = myData + " <icls:amount>25.00</icls:amount>"
myData = myData + " <icls:id>1</icls:id>"
myData = myData + " </incomeClassification>"
myData = myData + " </invoiceDetails>"
myData = myData + " <invoiceSummary>"
myData = myData + " <totalNetValue>25.00</totalNetValue>"
myData = myData + " <totalVatAmount>6.00</totalVatAmount>"
myData = myData + " <totalWithheldAmount>0.00</totalWithheldAmount>"
myData = myData + " <totalFeesAmount>0.00</totalFeesAmount>"
myData = myData + " <totalStampDutyAmount>0.00</totalStampDutyAmount>"
myData = myData + " <totalOtherTaxesAmount>0.00</totalOtherTaxesAmount>"
myData = myData + " <totalDeductionsAmount>0.00</totalDeductionsAmount>"
myData = myData + " <totalGrossValue>31.00</totalGrossValue>"
myData = myData + " <incomeClassification>"
myData = myData + " <icls:classificationType>E3_561_001</icls:classificationType>"
myData = myData + " <icls:classificationCategory>category1_1</icls:classificationCategory>"
myData = myData + " <icls:amount>25.00</icls:amount>"
myData = myData + " <icls:id>1</icls:id>"
myData = myData + " </incomeClassification>"
myData = myData + " </invoiceSummary>"
myData = myData + " </invoice>"
myData = myData + "</InvoicesDoc>"
req.send myData
Debug.Print req.responseText
ParseWiseOwlVideos req.responseText
.MoveNext
Loop
End With
If req.Status <> 200 Then
MsgBox req.Status & "-" & req.statusText
Exit Sub
End If
Debug.Print tXML
End Sub
From the following XML response, I need to extract UID and MARK and update table fields. The criteria for the update is <index> number.
<?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>
<index>1</index>
<invoiceUid>BAC9861A68546E5F7D2E7E0AF052E3F443B5174D</invoiceUid>
<invoiceMark>400001851984363</invoiceMark>
<statusCode>Success</statusCode>
</response>
</ResponseDoc>
Any help will be much appreciated
Regards
Jiannis