Why isn't the item after the Deserialize XML activity going into For Each?

Hi,
Why isn’t the item after the Deserialize XML activity going into For Each?

XMLCode.txt (1.8 KB)

Testt.xaml (34.6 KB)

RPA TEST.xlsx (10.7 KB)

we would recommend that you will handle properly the XML namespaces

1 Like

I did not understand the problem here. Can you help me?

Your soap XML is defining namespaces and should handle it as described in the LINK.

For a more fast help just let us know the requirements / what you want to achieve in general with the XML. But tell us the task not what was tried as e.g. prefix replaces are leading more to XY Problems and are off from requirement

  1. Read Excel file.
  2. Filter “Kurum Kodu” in column E and “Dönen Borç Adet” in column J in the Excel file.
  3. Read XML code from text file.
  4. Determine the data in the “Güncellenecek Değer” cell in column I in Excel in XML code. If there is more than one comma-separated value in column I, split it up and run for each value.
  5. Increase the detected value to value=value+1.
    **The important thing here is that if there is more than one value separated by commas in column I, each value should be updated.

As already mentioned above: SOAP XML will have the need to handle XML Namespaces (as described in the attached link)

the provided sample XML:

<?xml version="1.0" encoding="ISO-8859-9"?>
<soapenv:Envelope
    xmlns:soapenv="aaaaaaa"
    xmlns:tem="bbbbbbbbb/">
    <soapenv:Header/>
    <soapenv:Body>
        <ns9:getOpenInvoicesbyKeyResponse
            xmlns:ns9="ccccccccccc">
            <result>
                <bankId>1111</bankId>
                <compId>2222</compId>
                <curr>3333</curr>
                <errMsg>Yes</errMsg>
                <invCount>4444</invCount>
                <invoceList>
                    <anyType
                        xmlns:ns5="5555"
                        xmlns:xsi="6666" xsi:type="7777">
                        <controlId>8888</controlId>
                        <dueDate>2020311</dueDate>
                        <invAmount>99.99</invAmount>
                        <invNo>0123456789</invNo>
                        <invType>00000</invType>
                        <msisdn>9876543210</msisdn>
                        <nameSurname>dddddd eeeee</nameSurname>
                        <orderNo>88</orderNo>
                        <payAmount>1111</payAmount>
                        <period>202111</period>
                        <remark>000</remark>
                    </anyType>
                </invoceList>
                <msgDate>1213003550</msgDate>
                <orig>
                    <branch>8888</branch>
                    <city>0</city>
                    <teller>1</teller>
                    <user>XXXX9999</user>
                </orig>
                <queryKey>gsmNo</queryKey>
                <queryKeyValue>951753</queryKeyValue>
                <respCode>00</respCode>
                <stan>800111</stan>
            </result>
        </ns9:getOpenInvoicesbyKeyResponse>
    </soapenv:Body>
</soapenv:Envelope>

has no elments with the name: FaturaNo,IslemReferansNo
So there is nothing to loop by xd_XmlCode.Root.Descendants(GD.ToString)

You can cross check

I added the new code.

<?xml version="1.0" encoding="ISO-8859-9"?>
<soapenv:Envelope
    xmlns:soapenv="aaaaaaa"
    xmlns:tem="bbbbbbbbb/">
    <soapenv:Header/>
    <soapenv:Body>
        <ns9:getOpenInvoicesbyKeyResponse
            xmlns:ns9="ccccccccccc">
            <result>
                <bankId>1111</bankId>
                <compId>2222</compId>
                <curr>3333</curr>
                <errMsg>Yes</errMsg>
                <invCount>4444</invCount>
                <invoceList>
                    <anyType
                        xmlns:ns5="5555"
                        xmlns:xsi="6666" xsi:type="7777">
                        <controlId>8888</controlId>
                        <dueDate>2020311</dueDate>
                        <invAmount>99.99</invAmount>
                        <invNo>0123456789</invNo>
                        <invType>00000</invType>
                        <msisdn>9876543210</msisdn>
			<faturaNo>456789123</faturaNo>
			<IslemRefenrasNo>9514753</IslemReferansNo>
                        <nameSurname>dddddd eeeee</nameSurname>
                        <orderNo>88</orderNo>
                        <payAmount>1111</payAmount>
                        <period>202111</period>
                        <remark>000</remark>
                    </anyType>
                </invoceList>
                <msgDate>1213003550</msgDate>
                <orig>
                    <branch>8888</branch>
                    <city>0</city>
                    <teller>1</teller>
                    <user>XXXX9999</user>
                </orig>
                <queryKey>gsmNo</queryKey>
                <queryKeyValue>951753</queryKeyValue>
                <respCode>00</respCode>
                <stan>800111</stan>
            </result>
        </ns9:getOpenInvoicesbyKeyResponse>
    </soapenv:Body>
</soapenv:Envelope>

did some corrections on the XML

Verifying the Namespace needs (we assume that a different result can occur, once the real namespaces are applied, but chan be checked similar)

grafik
(good thing, we do not need here)

retrieve the IslemRefenrasNo elements xDoc.Descendants(“IslemRefenrasNo”)
e.g used for the each

Retrieve value, update value:
grafik
in your case loop variable name is item: item.Value = “NewValue String”, done within an assign

check the update:
grafik
Ok

Fazit:

  • it was not looping, due there was no element
  • special check for namespace is recommended on real used XML
  • updating the XML Value can be done as shown in the demo

I’m getting an error in the for each activity. What should I write in GD for each? I do not understand.

which error?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.