Deserialize XML from SOAP output

Hi,
I am trying to extract the ‘Price’ value from this SOAP XML output:

I am not able to what to put here in the Element() field:

Any ideas? I am not very proficient in XML so don’t know what tags to put there… Thanks

1 Like

see here

@nadim.warsi. thanks for the lightning fast reply Nadim!!!. i will try that

XML_Output.xml (990 Bytes)

To get price, I am using this in the XML element -

image
but it throws an error…

@jaspreet1003
Unfortunately WE cannot See the entire Statement. But your XML has defined namespaces. This you have to handle as well in Case of retrieval issues.

Just inspect in debugger the result of the Deserialize XML activity and you will know what to do :slight_smile:

@bcorrea. Hi Bruno, I tried…It gives this output…missing a tag here, may be?

image

2 Likes

You are looking at it as text, cant you see it as xml and element by element?

@jaspreet1003 You have to add another .Element(“PODetail”) after the first one because the first element called “PODetail” has a child element also called “PODetail”

@Dave. still the same error

@bcorrea. do i do that by a for loop?

@jaspreet1003 - i Just downloaded the XML you attached in an earlier post and it is different from the screenshot you provided. As @ppr mentioned, you will have to deal with the namespaces. I generally assign it as a XNamespace variable before working on any data extraction/manipulation so you can then reference it more easily. For example in an assign (of type XNamespace) assign ns1 = “http://xml.fultonhomes.com/Vendor”. Then when referencing elements you would have it be .Element(ns1 + “ElementName”).Element(ns1 + “NextElementName”)

You are gettting the error because you are trying to reference XML elements that do not exist. A good tip on how to debug this is to first check only the Root element and make sure it works. For example in a write line activity type in YourXDocument.Root.Name.ToString. Make sure the name is what you expect. If that works without error then add in the next child element so it’ll be YourXdocument.Root.Element(“Child1”).Name.ToString. Check to make sure it doesn’t error out. Continue doing this all the way down until you reach the final element you’re looking for.

Go ahead and give that a try and see if you are able to figure it out on your own. If you are still struggling with it I will be happy to help further

1 Like

@jaspreet1003

give me some mins and I can share a demo xaml with you

after you get the string response, you can also remove the namespace by passing like this to desserializae: MyResponseString.Replace(“NAMESPACE”,"") and then will be easy like this:
myxml.Descendants(“PODetail”).First().FirstNode()

2 Likes

This is brilliant and I’m not sure why I’ve never thought of it haha. I hate dealing with namespaces so much, especially when there are multiple namespaces like the example here

2 Likes

@Dave. yeah, I am trying the root first and like bcorrea said, i think its a white space in root which is causing this error:
image

The root shows up as:
image

@jaspreet1003
Have a look here, showcasing some initial retrieval actions:
jaspreet1003.xaml (8.6 KB)

some elaborations I will share with you soon

you need to remove from the xmlns= until Vendor’

@Dave. I tried the YourXDocument.Root.Name.ToString and this is the output Dave:
image

@ppr. Thanks Peter. Its showing as missing activity.