De-serializing XML (Soap response)

I need to Deserialize the below XML…

<s:Envelope xmlns:xsd=“XML Schema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:s=“http://schemas.xmlsoap.org/soap/envelope/”>
<s:Body>



InvokeSPUnaware
0



19




85
19179B42DHFK


76
UDHKHB466700










</s:Body>
</s:Envelope>

Need to get the BOT ID and the MESSAGE Id from every sub collection. Please help.

@Pradeep.Robot
for processing the xml it is required to handle namespaces. have a look here for starter help
SOAP_SearchByIDType.xaml (6.3 KB)
with
test.xml (862 Bytes)

@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”).toList, but have to filter on the name attribute: selectClaims

iterating over all found SubCollections the same has to applied and can be done as following:

LINQ

item.Elements("Column").Where(Function (x) x.Attribute("name").Value.Equals("WQDF_BOT_ID")).First().Value

(relying on element position index is not recommended)

XPATH

item.XPathSelectElement("Column[@name='WQMS_MESSAGE_ID']").Value

finally following log is written:
grafik

ensure that following imports are present:
grafik

find starter help here:
kk.virags.xaml (8.2 KB)

Let us know your feedback

2 Likes

Thanks Peter for the solution, I will try and let you know if it works. Just wanted to know few things.

  1. The above is two way of doing this? like LinQ and Xpath? where can i learn about how to define such attributes with respect to LinQ and Xpath?
  2. I see that, the LINQ statement is based on the x.Attribute(“name”).Value.Equals(“selectClaims”)).ToList… What if some of the sub collections has the different value in the subcollection Names? Which means, sometimes what if it comes “InsertClaims” or “DeleteClaims” ?
  3. Is there any way where i can jus look in to the direct Xpath of the WQMS_MESSAGE_ID? for each subcollections?

Thanks again for taking your time on helping this out.

@Pradeep.Robot
1: yes, there are alternates to implement the retrieval:
LINQ - XML (e.g. for starting)
XPath Tutorial

2: then the filter expression / logic has to modified. For doing this the requirements has to reformulate as in a first step.

3: give a try on (Not sure If I got your question right)

2 Likes

Thank you so much peter.

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