Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7959581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:35:46+00:00 2026-06-04T04:35:46+00:00

When I call the my service as below the XML elements TruckName and Website

  • 0

When I call the my service as below the XML elements TruckName and Website are null? Clearly the elements are poupulated in the XML on the web page (see xml below). I believe its related to the ArrayOf element being first? Below is also the code from my console app calling the method GetInfo(). Do I need to get rid of the ArrayOfFoodTruck element? If so whats the easiest way. thanks to all in advance..

- <ArrayOfFoodTruck xmlns="http://schemas.datacontract.org/2004/07/WCFServiceLibrary" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
- <FoodTruck>
 <Company i:nil="true" /> 
 <DayOfWeek i:nil="true" /> 
 <Location i:nil="true" /> 
 <TimeOfDay i:nil="true" /> 
 <TruckID>0</TruckID> 
 <TruckName>Truck 87</TruckName> 
 <Website>http://www.test.com</Website> 
 </FoodTruck>
- <FoodTruck>
<Company i:nil="true" /> 
<DayOfWeek i:nil="true" /> 
<Location i:nil="true" /> 
<TimeOfDay i:nil="true" /> 
<TruckID>0</TruckID> 
<TruckName>Bon Me</TruckName> 
<Website>http://www.test.com</Website> 
</FoodTruck>
</ArrayOfFoodTruck>

This is the call from my console app..

    static void GetInfo()
    {

        XElement rootXml = XElement.Load("http://localhost:5150/getnames");

         var FoodTruck = from C in rootXml.Elements()
         select new { TruckName = (string)C.Element("TruckName"), WebSite = (string)C.Element("Website") };
         foreach (var x in FoodTruck)

         Console.WriteLine("{0}\r\n{1}", x.TruckName, x.WebSite);
         Console.ReadKey();

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:35:46+00:00Added an answer on June 4, 2026 at 4:35 am

    I guess you have problem with the namespace

    XDocument xDoc = XDocument.Load(.....);
    XNamespace ns = XNamespace.Get("http://schemas.datacontract.org/2004/07/WCFServiceLibrary");
    
    var result = xDoc.Descendants(ns+"FoodTruck")
        .Select(n => new 
        { 
            TruckName=n.Element(ns+"TruckName").Value,
            WebSite = n.Element(ns+"Website").Value
        })
        .ToArray();
    

    –EDIT– OR

    XmlSerializer ser = new XmlSerializer(typeof(FoodTruck[]), "http://schemas.datacontract.org/2004/07/WCFServiceLibrary");
    var foodTrucks = (FoodTruck[])ser.Deserialize(new StringReader(xml));
    
    public class FoodTruck
    {
        public string Website;
        public string TruckName;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a RESTful web service call in my JavaScript page and get the
I am getting a response from a web service call in XML format. I
I am consuming a web service as its output is an XML string. I
I'm trying to find duplicates within the xml returned by a web service call
I am getting the error below when I call my WCF service. What am
I call a service which returns GMT dates. Its been working fine since November,
I have a synchronous web service call that returns a message. I need to
When trying to make a web service (hosted on a different server) call from
I have to call a Web service that is extremely demanding (unstandard) regarding the
I'm trying to call my Web Service which i created in Google Apple Engine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.