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
ppr
(Peter Preuss)
September 16, 2021, 10:21am
3
Have a Look Here on how to Deal with namespaces when extracting Data from XML
@Zlotzky
Setting up the quick prototype:
Variables:
Handling Namespace:
[grafik]
ElementNames to Extract - Prototype reduced set:
[grafik]
Read In XML
[grafik]
Ensure:
[grafik]
Retrieval of private contact element (mandatory use of the Namespace within the name)
[grafik]
iterating over the list of elmentnames (ExtractNames) and reading element value:
[grafik]
Logs:
[grafik]
Find starter help here:
Zlotzky.xaml (6.3 KB)
And Here
@Pradeep.Robot
Following up the communications from messages find some further starter help:
XML Namespaces can confuse sometimes. But with following it can be overcome and analysed. After deserializing into an XDoc following statement can be used for exploration in the watch Box / Immediate Box while debbuging:
[grafik]
playing with the index the element of interest can be checked if its dealing with any Namespace or not
with the LINQ XML methods we can use the Descendants(“SubCollection”)…
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?
ppr
(Peter Preuss)
September 17, 2021, 4:27pm
5
@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
ppr
(Peter Preuss)
September 17, 2021, 5:27pm
8
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.
ppr
(Peter Preuss)
September 18, 2021, 3:10pm
11
@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>
ppr
(Peter Preuss)
September 18, 2021, 3:27pm
13
As described in the links and mentioned set up the Namespaces
Quick check within the immediate panel:
Minimal RnD Flow:
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?
ppr
(Peter Preuss)
September 18, 2021, 3:45pm
15
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”
ppr
(Peter Preuss)
September 18, 2021, 3:49pm
17
we do assume that all is set up as described
check for following:
ye all the above are very much there.
ppr
(Peter Preuss)
September 18, 2021, 4:07pm
19
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
ppr
(Peter Preuss)
September 18, 2021, 4:18pm
21
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 ”