Deserialize XML from SOAP output

I encourage you to keep trying out all these solutions because there are many ways to solve every problem. I’ve noticed especially with XML navigation there are many ways to go about it. Here are 2 ways to get to the value you want based on the XML you uploaded earlier.

Step 1: Read the xml file as text
Step 2: Deserialize to an Xdocument
Step 3: Assign XNamespaces - this is done as 2 assigns because there are 2 namespaces being used to get to the value you want. Assign ns1 = "http://schemas.xmlsoap.org/soap/envelope/" and assign ns2 = "http://xml.fultonhomes.com/Vendor"
Step 4: Extract the value from the XML. This is where there are many different approaches you can take. If you want to navigate down the tree one by one it would look like this: Assign YourValue = XMLdoc.Root.Element(ns1 + "Body").Element(ns2 + "GetPODetailResponse").Element(ns2 + "GetPODetailResult").Element(ns2 + "PODetail").Element(ns2 + "PODetail").Element(ns2 + "price").Value

As you can see this is quite long. You can shorten it up by looking at the XML structure and making assumptions. I will assume that you always want to get the first price, from the first PODetail. With that assumption in place you can just use a single Descendants.FirstOrDefault statement to extract the value which is much shorter and works in this specific case:

Assign YourValue = XMLdoc.Descendants(ns2 + "price").FirstOrDefault().Value

EDIT: @jaspreet1003 Here is an .XAML showing both of the solutions Child1.xaml (7.1 KB)

3 Likes