Extract Element Values from SOAP XML (VB.Net / C#)

Dears,

I am very new to UI Path.

Can anyone here help me to Deserialize the following XML and also export the data into MS Excel?

<s:Envelope xmlns:s=“http”>

<s:Body xmlns:xsi=“http” xmlns:xsd=“http”>

  <Response xmlns="http">

     <Result>

        <DetailObject xmlns="">

           <IDNumber xmlns="http://abc.com/xml/schemas/version5.0">1234567890</IDNumber >

             <List xmlns="http://abc.com/xml/schemas/version5.0">

              <Details>

                 <Code>1111111</Code>                    

              </Details>

            </List>

       </DetailObject>

     </Result>

  </Response>

</s:Body>

</s:Envelope>
Thanks
Deepak

Hi @Deepak_Andriod

Welcome to Community!

Please refer to the Link below provided with steps!

Use Build datatable to build the column names and AddDatarow to add the values in Datatable and Finally WriteRange to Excel.

Regards

Have a Look Here on how to Deal with namespaces when extracting Data from XML

And Here

Since yesterday I tried different possible ways mentioned here , but I am not getting the expected output. Can someone please help me to deserialize the XML mentioned above?

@Deepak_Andriod
Yes sure we can help

  • please describe in detail what is needed / show expected sample output
  • please share with us the XML sample file as XML or txt file (above xml is corrupt displayed due the </> was not used

Thanks for support

Sorry I am unable to paste the correct XML file due to some restriction from the site Administrator, however the below pasted code is very close to the original XML file. Hope this is ok for you all to understand what i am looking for.

What I want is to extract the IDNumber and the Code from the XML file and insert the extracted value to an Excel Sheet.

Processing: 1.xml…

<s:Envelope xmlns:s="">
<s:Body xmlns:xsi="" xmlns:xsd="">



1234567890


1111111





</s:Body>

Thanks
Deepak

Please have a look on your provided XML.If not using format button XML is not usable for us. Maybe you can correct or share xml file. Thanks

Since i am a new user, i am unable to attach any file.

Any other way to post my xml file?

Thanks
Deepak

Sorry, new users can only put 2 links in a post.
Read more here on how to easily remove this restriction.

Above is what I am getting when I post my XML here.

@Deepak_Andriod
we kindly ask yout to use the </> format button from editior. Then we would see the xml properly

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <Response xmlns="http://tempuri.org/">
         <Result>
            <DetailObject xmlns="">
               <IDNumber xmlns="http://abc.com/xml/schemas/version5.0">1234567890</IDNumber >
    	 <List xmlns="http://abc.com/xml/schemas/version5.0">
                  <Details>
                     <Code>1111111</Code>                     
                  </Details>
	</List>
           </DetailObject>
         </Result>
      </Response>
   </s:Body>

As described in the links and mentioned set up the Namespaces

Quick check within the immediate panel:

Minimal RnD Flow:
grafik

Set breakpoint, Debug get paused and do qucit checking within immediate panel

xDoc.Root.Descendants(xnsTempuri + "Result")(0)
xDoc.Root.Descendants(xnsTempuri + "Result")(0).Descendants(xnsVersion + "IDNumber")(0).Value
xDoc.Root.Descendants(xnsTempuri + "Result")(0).Descendants(xnsVersion + "Code")(0).Value

So the acces can be adopted e.g first retrieving the result then the others. If needed also over loops when multiple value pairs are to extract.

Once the values are extracted, the you can write it to Excel e.g. directly (write Cell) or uising a datatable and write range

is xDoc the output of DeserialseXML?

yes it is - some links do also have attached a XAML. feel free to check it out there as well

trying to display the output of xDoc.Root.Descendants(xnsTempuri + “Result”)(0).Descendants(xnsVersion + “IDNumber”)(0).Value
in a message box and
it is throwing an error “Method Name Expected”

we do assume that all is set up as described
check for following:
grafik

ye all the above are very much there.

Please answer following questions seperately:

  • had you reviewed one of the XAML from the above links?
  • is xDoc of Datatype XDocument? Change and Check again. Tell us the result

had you reviewed one of the XAML from the above links? Yes.

is xDoc of Datatype XDocument? Yes

is it running? If not then share some screenshots from your implementation details with us. Thanks
For implementation / quickchecks the immediate panel is the better choice instead of using write line, log message, message box.

Also ensure that you had no Copy Paste issues and changed " to “ or ”