<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope> <soap:Body> <GetMovementResponse> <GetMovementResult> <Code>1</Code> <Message/> <Data></Data> <List> <Movement> <--- From here <Code>XXX</Code> <MovementType>XXX</MovementType> <DateMovement>2020-11-27T15:04:04.09</DateMovement> <OriginCompany> <ID>0</ID> </OriginCompany> <CenterCostSource> <ID>0</ID> <ExternalCode>1</ExternalCode> </CenterCostSource> . . . </Movement> +<Movement> +<Movement> . . .
if XmlDocument.ReadFrom(InStr, xmlDoc) then begin xmlnsMgr.AddNamespace('ns', 'http://www.company.com.br/Company'); if xmlDoc.SelectNodes('//ns:Movement', xmlnsMgr, xmlNodList) then begin foreach xmlNod in xmlNodList do begin xmlNod.SelectSingleNode('ns:OriginCompany/ns:ID', xmlnsMgr, xmlNod2); Message(xmlNod2.AsXmlElement().InnerText); end; end; end;
xmlnsMgr: XmlNamespaceManager;
Answers
How you already have the xml in a Instream, you can do something like this to get, by example, the value of OriginCompany/ID of every Movement
Where the variables are:
Regards
I tried your method but unfortunately it doesn't access the line:
I skipped that line and it shows me the following error:
Microsoft.Dynamics.Nav.Runtime.NavXmlNode variable not initialized.
I do not know if it is related to the fact that I did not enter the mentioned line
Could you elaborate what means "it doesn't access the line"
Regards.
What I mean, at runtime it doesn't execute the "foreach" block, so it skips these lines:
Then the problem is in the previous line, that is not selecting any node.
Could you post a reduced version of the XML file that you are reading ?
Regards
I had contemplated it and tried this procedure. However, it does not fill the table correctly
I only consider three fields but this process does not fill them correctly
This is just an extract, the XML contains many more nodes called "Movimentacao"
With this XML you need to use a name space manager to deal with the lien in green in the image.
And this is the new var:
Regards
I applied the example and that solves the problem. Thank you.
Could you post how are you trying to insert the data in the BC table ?
Regards.