troubleshooting Question

Consuming XML sopa webservice in MVC 4

Avatar of Stanton_Roux
Stanton_RouxFlag for South Africa asked on
ASP.NETC#
2 Comments1 Solution902 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
guvera

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros