Avatar of Stanton_Roux
Stanton_Roux
Flag for South Africa asked on

Consuming XML sopa webservice in MVC 4

Hi There

I have a soap webservice that returns XML in the following way.

<Response xmlns="">
  <Regions>
    <Region>Eastern Cape</Region>
    <Region>Free State</Region>
    <Region>Gauteng</Region>
    <Region>KwaZulu-Natal</Region>
    <Region>Limpopo</Region>
    <Region>Mpumalanga</Region>
    <Region>Northern Cape</Region>
    <Region>North West</Region>
    <Region>Western Cape</Region>
  </Regions>
  <Result>
    <StatusCode>1</StatusCode>
    <ErrorCode>1</ErrorCode>
    <ErrorDescription>Success</ErrorDescription>
  </Result>
</Response>

I would like to know how to create a list from the XML in MVC 4 to populate a select list

ViewBag.RegionId = new SelectList(GetRegions(),"Description");

 public IEnumerable<Region> GetRegions()
        {
           var regions = new List<Region>();

           var strXMl2 = vws.GetRegions().;

         loop through xml
         
          regions.Add()

            return regions;
        }

public class Region
    {
       
        public string Description { get; set; }

       
    }

Any help will be appreciated

Thanks
Stanton
ASP.NETC#

Avatar of undefined
Last Comment
Stanton_Roux

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
guvera

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Stanton_Roux

ASKER
Thanks very much excellent answer
Your help has saved me hundreds of hours of internet surfing.
fblack61