UiPath Deserialize XML Multiple Data Extraction

Hello,
I want to do UiPath Deserialize xml multiple data extraction. For example, the following code contains a variable number of tags. I need to get the value of how many tags there are in XML. If there is 1 , I can get its value, but if there is more than one, I cannot get the value. Can you help me?
Thanks,

xd_XmlCode.Element(“soapenvEnvelope”).Element(“soapenvBody”).Element(“OdemeOncesiFaturaSorgulamaResponse“).Element(“faturaBilgiDizi”).Element(“faturaBilgi”).Element(“faturaNo”).Value.ToString
<soapenvEnvelope
    xmlnssoapenv="http//schemas.xmlsoap.org/soap/envelope/"
    xmlnstem="**/">
    <soapenvHeader/>
    <soapenvBody>
     <OdemeOncesiFaturaSorgulamaResponse xmlnsns3="**">
  <s606mesajTipi xmlnss606="**">210</s606mesajTipi>
  <s607islemKodu xmlnss607="**">91</s607islemKodu>
  <s608stan xmlnss608="**">62549114</s608stan>
  <s609kurumKodu xmlnss609="**">2111</s609kurumKodu>
  <islemYapan xmlns="**">
    <sehirKodu>34</sehirKodu>
    <subeKodu>00040020</subeKodu>
    <giseKodu>00000001</giseKodu>
    <kullaniciKodu>**</kullaniciKodu>
  </islemYapan>
  <s610sirketKodu xmlnss610="**">510</s610sirketKodu>
  <s611paraKodu xmlnss611="**">949</s611paraKodu>
  <s612islemKaynagi xmlnss612="**">8</s612islemKaynagi>
  <s613islemTarihi xmlnss613="**">20210823</s613islemTarihi>
  <s614islemSaati xmlnss614="**">234429</s614islemSaati>
  <ozetCevapMesaj xmlns="**">
    <hataMesaji>Başarılı işlem</hataMesaji>
    <islemSonucKodu>00</islemSonucKodu>
  </ozetCevapMesaj>
  <kayitSayisi>2</kayitSayisi>
  <erisimBilgi>
    <erisimTipi>1</erisimTipi>
    <erisimNo>7050000001</erisimNo>
  </erisimBilgi>
  <faturaBilgiDizi>
    <faturaBilgi xmlnsxsi="http//www.w3.org/2001/XMLSchema-instance" xsitype="OdemeOncesiFaturaBilgi">
      <hesapNo>7050000001</hesapNo>
      <toplamBorcTutari>1350</toplamBorcTutari>
      <referansNo>11111111111111</referansNo>
      **<faturaNo>888888888888888</faturaNo>**
      <faturaTaksitNo>0</faturaTaksitNo>
      <odemeDonemi>202107</odemeDonemi>
      <hesapId>159753</hesapId>
      <faturaEsnekAlan>
        <anahtarDegerCifti>
          <ns1anahtar xmlnsns1="**">komisyonKodu</ns1anahtar>
          <ns1deger xmlnsns1="**">0</ns1deger>
        </anahtarDegerCifti>
      </faturaEsnekAlan>
      <referansBilgi xsinil="1" />
      <adsoyadUnvan>**</adsoyadUnvan>
      <faturaTipi>0</faturaTipi>
      <sonOdemeTarihi>20221231</sonOdemeTarihi>
      <maliyetFaturaID>**</maliyetFaturaID>
    </faturaBilgi>
    <faturaBilgi xmlnsxsi="http//www.w3.org/2001/XMLSchema-instance" xsitype="OdemeOncesiFaturaBilgi">
      <hesapNo>123456789</hesapNo>
      <toplamBorcTutari>4205</toplamBorcTutari>
      <referansNo>1597555</referansNo>
      **<faturaNo>9999999999999999999</faturaNo>**
      <faturaTaksitNo>0</faturaTaksitNo>
      <odemeDonemi>202107</odemeDonemi>
      <hesapId>159753</hesapId>
      <faturaEsnekAlan>
        <anahtarDegerCifti>
          <ns1anahtar xmlnsns1="**">komisyonKodu</ns1anahtar>
          <ns1deger xmlnsns1="**">0</ns1deger>
        </anahtarDegerCifti>
      </faturaEsnekAlan>
      <referansBilgi xsinil="1" />
      <adsoyadUnvan>**</adsoyadUnvan>
      <faturaTipi>0</faturaTipi>
      <sonOdemeTarihi>20221231</sonOdemeTarihi>
      <maliyetFaturaID>159753</maliyetFaturaID>
    </faturaBilgi>
  </faturaBilgiDizi>
</OdemeOncesiFaturaSorgulamaResponse>
    </soapenvBody>
</soapenvEnvelope>

Hi @ridvanucok,

Please have a look if the below thread can help you.

Thanks

1 Like

grafik

Line1: we can check for the count
Line2: we can retrieve all elements and pass it e.g. to a for each
Line3/4 discrete retrieval


grafik

1 Like

I made the variable of the Deserialize XML activity xDocument. I made xElement as you showed in For Each E but it got an error.

Item = xd_XmlCode.Root.Descendants(“FaturaNo”)(0).Value

Error Message: For Each: Unable to cast object of type ‘System.Char’ to type ‘System.Xml.Linq.XElement’.


when deserialzing the XML you will get returned a XDocument
when looping over the elements we do set the typeargument to XElement
for retrieving the value as done by xDoc.Root.Descendants(“faturaNo”)(0).Value we will get back a string

in your screenshot you are mixing up retrieval and looping

grafik

3 Likes

Thanks for your help :slight_smile:

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